Specifications
Sun Services
Java™ Programming Language
Module 9, slide 15 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Simple Formatted Input
• The Scanner API provides a formatted input function.
• A Scanner can be used with console input streams as
well as file or network streams.
• You can read console input as follows:
1 import java.io.*;
2 import java.util.Scanner;
3 public class ScanTest {
4 public static void main(String [] args) {
5 Scanner s = new Scanner(System.in);
6 String param = s.next();
7 System.out.println("the param 1" + param);
8 int value = s.nextInt();
9 System.out.println("second param" + value);
10 s.close();
11 }
12 }










