How to print the output in two separate lines?

前端 未结 3 771
面向向阳花
面向向阳花 2021-01-24 19:50

I\'ve been trying to print the output in two separate lines, I used System.out.println() and also System.out.println(\"\\n\") but I only seem to be get

3条回答
  •  再見小時候
    2021-01-24 20:18

    If i understand your question correctly, may be this is what you need

    public void readFromTerminal() {
        System.out
                .println("Read lines, please enter some other character to stop.");
        int check = 0;
        while (true) {
            check = input.nextInt();
            al.add(check);
            if (check == 0) {
                break;
            }
    
        }
    
        for (int i : al) {
            System.out.print(i+ "\n");
        }
    }
    

提交回复
热议问题