// File : ScannerApp.java
// Purpose: Write to and read from the console.
import java.util.*; //Note 1
public class ScannerApp {
public static void main(String[] args) {
//... Initialization
String name; // Declare a variable to hold the name.
Scanner in = new Scanner(System.in);
//... Prompt and read input.
System.out.println("What's your name?");
name = in.nextLine(); // Read one line from the console.
in.close(); //Note 2
//... Display output
System.out.println("Take me to your leader, " + name);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment