Getting Input(Johny5) and Giving Output:
In order to get input we use a thing called a Scanner which basically takes input from the system and stores it into a scanner variable Here is how to use it:
- import Scanner
- Scanner input = new Scanner(System.in)
- System.out.print(What would you like to output: ") // This causes the cursor to show on this line
- String inStr = input.nextLine();
- System.out.println(inStr);
Here is the above example in use:
No comments:
Post a Comment