Try this instead:
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
System.out.print("? ");
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
System.out.println("You entered: " + input);
scanner.close(); // Close the scanner after you do not need it anymore.
}
}