![]() |
The Future Is Behind You |
Home | About | Stories | Blog | Poetry | Programming |
Keyboard InputThe Scanner class can be used to get input from the user at the keyboard. import java.util.Scanner; public class Keyboard { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.print("enter a number: "); int num = keyboard.nextInt(); System.out.println("You entered: " + num); } } Here's how the program runs and some sample input/output. $ java Keyboard enter a number: |
Copyright © 2003 - 2021 Kyle Eggleston |
a = b = c |