java read input from stdin code example
Example 1: 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);
}
}
Example 2: java stdin
public static void main(String[] args) {
StdOut.print("Type an int: ");
int a = StdIn.readInt();
StdOut.println("Your int was: " + a);
StdOut.println();
}
}