how to scan for a string in java code example
Example 1: java scanner
import java.util.Scanner;
Scanner myScanner = new Scanner(System.in);
String inputString = myScanner.nextLine();
boolean inputBoolean = myScanner.nextBoolean();
long inputLong = myScanner.nextLong();
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);
}
}