0

I would like to be able to read the next key the user presses into the console, I have not been able to find anything that was working, and by the way I am pretty new to Java. It should work like Console.Readkey() in C# .

What it should not require enter to read the key. The answer on readkey in java does not seem to work that way. Else I would like an answer that explains how it works

Community
  • 1
  • 1

1 Answers1

0

You can use :

Scanner scan = new Scanner(System.in);
String x = scan.nextLine();
String y = scan.nextLine();

To print your value you can use :

System.out.println("X = " + x);
System.out.println("Y = " + y);
Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140