You are viewing a single comment's thread. Return to all comments →
will you please explain
System.out.println(i + " " + scan.nextLine());
I am new to java
It's equivalent to this code:
String line = scan.nextLine();
System.out.println(i + " " + line);
replace System.out.println(i + " " + line);
System.out.println(i + " \t" + line);
it prints the current i value. And the Double inverted commas work as giving space between the value of i and the value of the scan object value that has been read by the compiler entered by the user.
it prints number(i) plus space(" ") plus the next line
In Stdout first of all current value of i will be print than " " will genrate space and scan.nextLine() will print value read by compiler.
For example if i=1 and complier reads input such as "Hello Eveyone !" so it will be printed like this:
1 Hello Eveyone !