Advertisement
Guest User

nextInt NextLine problem

a guest
May 9th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. package testprojects;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class NextLineProblem {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner console = new Scanner(System.in);
  10.         int length = console.nextInt();
  11.         String[] strings = new String[length];
  12.         console.nextLine();
  13.         for (int index = 0; index < length; index++) {
  14.  
  15.             strings[index] = console.nextLine();
  16.         }
  17.  
  18.         for(String str:strings){        
  19.             System.out.println(str);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement