How to take string input in Java?

To read a string in Java, do this: new Scanner(System.in).nextLine().

Here's how you do it:

System.out.print("Awaiting your input: ");

String input = new java.util.Scanner(System.in).nextLine();

System.out.format("Your input was: %s", input);