0
Scanner in for loop
What is the problem? import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for(int i=0; i<num; i++){ String name = sc.nextLine(); String[] str = name.split(" "); System.out.println(str[0]); System.out.println(str[1]); } } }
4 Answers
+ 2
Could you please tell us that what are you trying to achieve with this piece of code. What is the input like and what is the output you are expecting out of it?
0
for exemple u can insert 3 as first input, and a string (name family) as second one.