It is a simple demonstration to show how to take a string as an input from the user.
The only thing you need to be concerned about is the data type that you declare in the program that is the String data type as shown below in the program.
How to take user Input as String in java
//user String input in java
public class UserInput
public static void main(String args)
Scanner in = new Scanner(System.in);
//Get input String
System.out.println("Enter a string: ");
str = in.nextLine();
System.out.println("Entered String is: "+str);
Enter a string:
I am Coding right now.
Entered String is: I am Coding right now.