Monday, 23 October 2017

How to Use Java Scanner Class


Program:


import java.util.*;
public class InputValues
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);

// Your name
System.out.print("What is your name? ");
String name = in.nextLine();

// Your age
System.out.print("How old are you? ");
int age = in.nextInt();
System.out.println("Hello, " + name + ". Your Age is "+ age +". Nice to Meet You");
}
}


Output:
Hello, bsb. Your Age is 23. Nice to Meet You

No comments:

Post a Comment

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...