0
Why in java you have to give a space input btw int input and Line input?
when we have to take input from scanner , than we have to take a blank input BTW an Int input and Line input. I want to know why we have to add that blank input? for example: Scanner input = new Scanner(System.in); int a; String name; a = input.nextInt(); input.nextLine(); name =input.nextLine(); So ,why we need that input.nextLine(); BTW the input of a and name.
2 Answers
+ 1
In Sololearn,the input box says "Separate multiple inputs by multiple lines". Hence users write there next input (in example, its name) in next line.
So if we dont use input.nextLine(); then the name will get null value(as there is no value after user's first input (in example its a))
0
but it is not applicable only on sololearn