Tuesday 16 August 2016

Java Tutorial : Java IO (Scanner class)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=2eCPzJb5I6c&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
Java Tutorial : Java IO (Scanner class) 
ScannerDemo.java
import java.util.Scanner;

/*
 *  Java Scanner class which reads the int, 
 *  string and double value as an input:
 */
public class ScannerDemo
{

    public static void main(String[] args)
    {
        Scanner scanner = null;
        try
        {
            scanner = new Scanner(System.in);

            System.out.print("Enter your Id: ");
            int rollno = scanner.nextInt();

            System.out.print("Enter your Name: ");
            String name = scanner.next();

            System.out.print("Enter your Weight: ");
            double weight = scanner.nextDouble();

            System.out.println("Id:" + rollno + ", Name:" + name
                    + ", Weight:" + weight);
        }
        finally
        {
            if (scanner != null)
            {
                scanner.close();
            }
        }
    }
}
Output
Enter your Id: 54
Enter your Name: peter
Enter your Weight: 67.89
Id:54, Name:peter, Weight:67.89
Refer: 
https://docs.oracle.com/javase/8/docs/api/index.html?java/util/Scanner.html
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_Scanner_Intro_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_Scanner_Intro_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ebaa49adbc935437412c3f95a1070f272f5231dd/BasicJava/JavaIODemo_Scanner_Intro_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment