java taking console input
String str = System.console().readLine();
java taking console input
String str = System.console().readLine();
java read input from user
import java.util.Scanner; /* Required Import*/
public class reading{
public static void main(String[] args){
Scanner scan = new Scanner(System.in); // Create Reader
System.out.print("Enter Your Age"); // Ask the user for something
int age = scan.nextInt(); // Read value from user
System.out.print(age); // Output the value
}
}
/*
Java Reading Options:
1_ reading int => nextInt();
2_ reading char => next().charAt(0); Single Character
3_ reading string => next();
4_ reading double => nextDouble();
*/
how to get user input in java
import java.util.*;
class UserInputDemo
{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in); //System.in is a standard input stream
System.out.print("Enter first number- ");
int a= sc.nextInt();
System.out.print("Enter second number- ");
int b= sc.nextInt();
System.out.print("Enter third number- ");
int c= sc.nextInt();
int d=a+b+c;
System.out.println("Total= " +d);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us