+ 4
Is there any getch() equivalent in java?
2 odpowiedzi
+ 13
You may try the following way:
Scanner in = new Scanner (System.in);
char a = in.next();
If you're referring to any character which is not supposed to be saved as a variable, then you may use the following :
in.next(); // it'll consume the extra character
+ 3
Use
new Scanner(System.in) with out any variable
That's all
Example of I mean:
public class ILikeCow{
public static void main(String[] ouch){
java.lang.System.out.print("....");
//I like to use java.lang.System =-=
new java.util.Scanner(java.lang.System.in);
java.lang.System.out.print("I prefer cow than java.lang.System");
//This getch() is certainly not working in code playground
//If this thing compile with error then I'm srry
}
}