Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Is nextLine a keywords??
import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); System.out.println(myVar.nextLine()); } }
2 Answers
+ 9
nextLine() is a method defined in Scanner class. It's used to take String input. Similarly, there are separate methods for taking int, double, boolean inputs (nextInt(), nextDouble(), nextBoolean() etc.)
See the official documentation for more details:
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
+ 1
Thank uShamima Yasmin