Java 我无法使用递归正确打印输出

Java 我无法使用递归正确打印输出,java,eclipse,networking,recursion,Java,Eclipse,Networking,Recursion,我是个网络新手。我需要设计具有以下拓扑结构的网络: The network consists of a number of N hops where each hop is directly connected to the next hop. The objective is to send a packet from the first hop to the last hop. I need to imposes the following restrictions on the rou

我是个网络新手。我需要设计具有以下拓扑结构的网络:

The network consists of a number of N hops where each hop is directly connected to the next hop.

The objective is to send a packet from the first hop to the last hop.

I need to imposes the following restrictions on the routing of packets:

    A packet can either pass by a hop, or stop at a hop. At first, no modifications should be done to the packet; the packet is only forwarded to the next hop straight away. In the later case, the packet is modified before being forwarded to the next hop which takes some processing time.

    When a packet stops at a hop, there is a maximum number of hops that the packet is allowed to pass through after leaving the hop before stopping again.
我还需要创建一个int[]getMinStopsRec()方法:该方法实现了一个简单的递归解决方案,用于返回一个新整数数组中输入数组中由其索引表示的跳序列

我的问题是我不能使用递归打印输出

这是我的密码

public class Hops {

    private static int[] numberOfHops;
    private static int counter = 0;

    public Hops(int[] hops) {
        numberOfHops = hops;
    }

    private int[] getMinStopsRec() {
        ArrayList<Integer> list = new ArrayList<Integer>();
        int[] newArray = new int[3];
        counter++;

        if (counter <= 10) {

            switch (numberOfHops[counter]) {

                case 1:
                    list.add(3);
                    break;
                case 2:
                    list.add(1);
                    list.add(4);
                    break;
                case 3:
                    list.add(0);
                    list.add(1);
                    list.add(3);
                    list.add(10);
                    break;
                case 4:
                    list.add(0);
                    list.add(2);
                    list.add(4);
                    break;
                case 5:
                    list.add(0);
                    list.add(3);
                    list.add(5);
                    break;

                case 6:
                    list.add(3);
                    list.add(8);
                    list.add(10);

                    break;
                case 7:
                    list.add(5);
                    list.add(7);
                    list.add(10);

                    break;
                case 8:
                    list.add(3);
                    list.add(8);
                    list.add(10);

                    break;
                case 9:
                    list.add(3);
                    list.add(6);
                    list.add(10);

                    break;

                default:

                    System.out.println("Invalid number : " + counter);
                    break;

            }

            newArray = new int[list.size()];

            for (int i = 0; i < list.size(); i++) {
                newArray[i] = list.get(i);

            }

            return getMinStopsRec();


        }

        return newArray;
    }
}
公共类跃点{
私有静态int[]跳数;
专用静态整数计数器=0;
公共跃点(int[]跃点){
numberOfHops=跳数;
}
私有int[]getMinStopsRec(){
ArrayList=新建ArrayList();
int[]newArray=newint[3];
计数器++;
if(计数器