Wednesday, November 7, 2012

Scanner Demo


package com.lenin.util;

import java.util.Scanner;

public class ScannerDemo {

      public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.print("Enter a string:");
            String data = scanner.nextLine();
            System.out.println("The string entered is :" + data);
            System.out.print("Enter an integer number:");
            int intNumber = scanner.nextInt();
            System.out.println("The int number entered is :" + intNumber);
      }
}

No comments:

Post a Comment