Scanner nextLine() ,nextInt() ,nextDouble() method in Java with Examples
Categories: Java 9 Java 8(JDK1.8) Java Java Examples
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("Enter your name:-");
String name=scanner.nextLine();
System.out.println("Hello "+name);
System.out.println("Enter your age");
int age=scanner.nextInt();
System.out.println("Your Age-"+age);
System.out.println("Enter your sallary");
double sallary=scanner.nextDouble();
System.out.println("Your Sallary-"+sallary);
}
}
OutputEnter your name:-
Rajesh Kumar
Hello Rajesh Kumar
Enter your age
31
Your Age-31
Enter your sallary
1900000
Your Sallary-1900000.0