小编use*_*452的帖子

递归代码到非递归循环

你好,我希望这个代码非递归我怎么能这样做?

public class test {

    public static void main(String[] args) {
        int[] array = new int[]{0, 1, 2,3};
        int size = 2;
        int[] tmp = new int[size];
        //Arrays.fill(tmp, -1);
        generateCombinations(array, 0, 0, tmp);
    }

    private static void generateCombinations(int[] array, int start, int depth, int[] tmp) {

        if (depth == tmp.length) {
            for (int j = 0; j < depth; j++) {
                System.out.print(array[tmp[j]]);

            } System.out.println();
            return;
        }
        for (int i = start; i < array.length; i++) {
            tmp[depth] = i;
            generateCombinations(array, …
Run Code Online (Sandbox Code Playgroud)

java combinations

5
推荐指数
1
解决办法
234
查看次数

改造和活动生命周期

我想用Android创建一个REST客户端,我读到了有关改造的内容.当我通过改造执行一些请求时,即使活动被销毁,也会执行回调.

在活动被销毁后如何停止接收响应?

apiService.getDummieContent().enqueue(new Callback<ResponseBody>() {
    @Override
    public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {

    }

    @Override
    public void onFailure(Call<ResponseBody> call, Throwable t) {

    }
});
Run Code Online (Sandbox Code Playgroud)

android retrofit2

3
推荐指数
1
解决办法
2815
查看次数

标签 统计

android ×1

combinations ×1

java ×1

retrofit2 ×1