I was trying to take string input in java. My input should be like this
3 1,1,[email protected],123 Sesame St.,New York,NY,10011,12345689010 1,2,[email protected],123 Sesame St.,New York,NY,10011,12345689010 1,3,[email protected],123 Sesame St.,New York,NY,10011,12345689010 So, I tried this
Scanner in = new Scanner(System.in); int TotalNumber = in.nextInt(); String[] Data = new String[TotalNumber]; for (int Counter = 0; Counter < TotalNumber; Counter++) { Data[Counter] = in.next(); } in.close(); for (int counter = 0; counter < Data.length; counter++) { System.out.println(Data[counter]); } My output is showing this
1,1,[email protected],123 Sesame St.,New What is my problem ? How take input string line properly ?
Update
I found my solution at here Scanner issue when using nextLine after nextXXX