+ 1

When using scanner in java, what is use of nextLine()?

I mean for this program Scanner x=new scanner (system.in) ; System. out. println(x.nextLine ()) ; //why nextLine() is used? What does this mean and what is it's importance. It will be very helpful. Guys I am very beginner here.

26th Sep 2020, 9:12 AM
Yugal Kishore
4 Antworten
+ 5
nextLine() is used when String inputs are taken just like nextInt() is used when integer inputs are taken
26th Sep 2020, 9:20 AM
Piyush
Piyush - avatar
+ 2
26th Sep 2020, 9:24 AM
Avinesh
Avinesh - avatar
+ 1
Thanks guys.
26th Sep 2020, 9:40 AM
Yugal Kishore
0
nextLine() is a method of Scanner class. So, using the object of Scanner class u can able to call that function and the main use of that method is to take string input from the user. So, after compilation it ask you to enter a string and outputs it.
26th Sep 2020, 9:31 AM
sarada lakshmi
sarada lakshmi - avatar