take input string and string input java code example
Example 1: taking string input in java
Scanner in = new Scanner(System.in);
String s = in.nextLine();
Example 2: java read string input
import java.util.Scanner;
public class YourClass {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String inputString = scanner.nextLine();
System.out.println("Your string: " + inputString);
}
}