How to get Input from User in Java

import java.util.Scanner;

class getuserinput
{
public static void main(String args[])
{
int a;
float b;
String c;
System.out.println("Enter integer");
a = in.nextInt();
System.out.println("The Value is "+a);
Scanner in = new Scanner(System.in);
System.out.println("Enter float");
b = in.nextFloat();
System.out.println("The Value is "+b);  
System.out.println("Enter string");
c = in.nextLine();
System.out.println("The Value is "+c);
}
}

No comments:

Post a Comment

My Profile