Menu



Java program for input through console


InputFromConsole.java

import java.util.Scanner;
class InputFromConsole
{
public static void main(String args[])
{
int a;
float b;
String s;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string");
s = sc.nextLine(); //scans the data for input of string
System.out.println("You entered string "+s);
System.out.println("Enter an integer");
a = sc.nextInt(); //scans the data for input of integer
System.out.println("You entered integer "+a);
System.out.println("Enter a float");
b = sc.nextFloat(); //scans the data for input of float
System.out.println("You entered float "+b);
}
}

Output

input from console









Connection failed: SQLSTATE[28000] [1045] Access denied for user 'studentdb'@'localhost' (using password: YES)

Subscribe