+ 1
how to take input from user with exmple
4 Réponses
+ 2
Simply Google search the Scanner class. You will find many examples
+ 2
what do you mean? like how to let the user interact with your program if so th code is:
playerAnswer = scan.nextLine ();
im sure you know about if, else, and else if statements so just do that for your users options. and if your doing a console game and want to make sure the user can only type one of the options, put that code and the other statements within a while loop thats set to true. the reason why you should do this is because if for example you have two options apple and pear and the player says orange. if you put a message in there some where saying "sorry, answer not recognized" it will say that message and repeat the question. hope that helped :)
+ 1
you can take input by using BufferedReader class and Scanner clsss
0
here is how i do it:
Scanner scannerVariable = new Scanner(System.in);
String userInput;
//This scans for input and stores it in the string
userInput = scannerVariable.nextLine();