How to read input with multiple lines in Java

后端 未结 10 1174
名媛妹妹
名媛妹妹 2020-12-05 02:48

Our professor is making us do some basic programming with Java, he gave a website and everything to register and submit our questions, for today I need to do this one exampl

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 03:34

     public class Sol {
    
       public static void main(String[] args) {
    
       Scanner sc = new Scanner(System.in); 
    
       while(sc.hasNextLine()){
    
       System.out.println(sc.nextLine());
    
      }
     }
    }
    

提交回复
热议问题