to get java input code example
Example 1: how to take input in java
Scanner sc = new Scanner(System.in);
String userName = sc.nextLine();
int age = sc.nextInt();
long mobileNo = sc.nextLong();
double cgpa = sc.nextDouble();
System.out.println(userName);
Example 2: input java
Scanner in = new Scanner(System.in);
System.out.print("Please enter hour 1: ");
int hour1 = in.nextInt();
System.out.print("Please enter hour 2: ");
int hour2 = in.nextInt();
System.out.print("Please enter minute 1: ");
int min1 = in.nextInt();
System.out.print("Please enter minute 2: ");
int min2 = in.nextInt();
Example 3: java get input
Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = sc.nextInt();
double d = sc.nextDouble();
float f = sc.nextFloat();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
int c = br.read();