how to take input in java
Java
Scanner sc = new Scanner(System.in); // Create a Scanner object
String userName = sc.nextLine();//read input string
int age = sc.nextInt(); //read input integer
long mobileNo = sc.nextLong(); //read input long
double cgpa = sc.nextDouble(); //read input double
System.out.println(userName);//output Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = sc.nextInt();
double d = sc.nextDouble();
float f = sc.nextFloat();
// more fast way
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine(); // read line
int c = br.read(); // read single charimport java.util.Scanner; // Import the Scanner class
class MyClass {
public static void main(String[] args) {
Scanner myObj = new Scanner(System.in); // Create a Scanner object
System.out.println("Enter username");
String userName = myObj.nextLine(); // Read user input
System.out.println("Username is: " + userName); // Output user input
}
}InputUSer Scanner
Also in Java:
- Title
- java android show toast
- Category
- Java
- Title
- how to make an arraylist java
- Category
- Java
- Title
- get method of a class which I only have string to
- Category
- Java
- Title
- Matlab java.lang.IllegalArgumentException: Invalid range
- Category
- Java
- Title
- java string to boolean
- Category
- Java
- Title
- jbutton open jframe java
- Category
- Java
- Title
- binary number input in int java
- Category
- Java
- Title
- counting the sequence of character in string java
- Category
- Java
- Title
- java while loop break
- Category
- Java
- Title
- java string contains char
- Category
- Java
- Title
- android studio remove navigation bar
- Category
- Java
- Title
- store string elements in character array in java
- Category
- Java
- Title
- compareto method java
- Category
- Java
- Title
- checking if a given integer is a prime number java
- Category
- Java
- Title
- bukkit java get max players
- Category
- Java
- Title
- convert java list to array
- Category
- Java
- Title
- Jlabel icon
- Category
- Java
- Title
- get world by name bukkit
- Category
- Java
- Title
- number of matches regex java
- Category
- Java
- Title
- java how to define a function
- Category
- Java
- Title
- firebase connecten
- Category
- Java
- Title
- map java
- Category
- Java
- Title
- java 8 string to localdate
- Category
- Java
- Title
- transformer un string en double java
- Category
- Java
- Title
- how to create array of linkedlist in java
- Category
- Java
- Title
- displaying an arraylist in java
- Category
- Java
- Title
- how to push an element in hashset java
- Category
- Java
- Title
- Java nested array hashcode
- Category
- Java
- Title
- Fab to CircularRevealFrameLayout example
- Category
- Java
- Title
- remove last character from string java
- Category
- Java
- Title
- kotlin jsonobject get nested
- Category
- Java
- Title
- how to initialize an array in java
- Category
- Java
- Title
- how to make a searchable list in java
- Category
- Java
- Title
- java iterator example
- Category
- Java
- Title
- math minimum java
- Category
- Java
- Title
- inheritance setter and getter in java
- Category
- Java
- Title
- action on long press of edit edittext
- Category
- Java
- Title
- java create file
- Category
- Java
- Title
- java sum of two numbers program intellij
- Category
- Java
- Title
- trees in java
- Category
- Java
- Title
- java cmd install raspbian
- Category
- Java
- Title
- money value commas java
- Category
- Java
- Title
- how to break from a loop in java
- Category
- Java
- Title
- how to convert a jsonobject to a dbobject
- Category
- Java
- Title
- java classes and methods
- Category
- Java
- Title
- summary of operator java
- Category
- Java
- Title
- new hashmap java
- Category
- Java
- Title
- switch java 11
- Category
- Java
- Title
- java get excectuon time
- Category
- Java
- Title
- how get started with LWJGL 3
- Category
- Java
- Title
- count word in string no matter the delimiter java
- Category
- Java
- Title
- java create folder
- Category
- Java
- Title
- array null pointer java
- Category
- Java
- Title
- spigot title
- Category
- Java
- Title
- java for each
- Category
- Java
- Title
- iterate trough linked list java
- Category
- Java
- Title
- java scanner
- Category
- Java
- Title
- java map foreach
- Category
- Java
- Title
- system.out.println shortcut
- Category
- Java
- Title
- testing the web layer without authentication spring
- Category
- Java
- Title
- lightweight java game library
- Category
- Java
- Title
- java min function
- Category
- Java
- Title
- java execute jar from main
- Category
- Java
- Title
- java script print date in YYYY-MM-DD format
- Category
- Java
- Title
- how to get the max value of an array java
- Category
- Java
- Title
- changing double space to single in java script
- Category
- Java
- Title
- selection sort in java
- Category
- Java
- Title
- JOptionPane with drop down list java
- Category
- Java
- Title
- java split string on two or more spaces except for words in quotes
- Category
- Java
- Title
- java creare costante
- Category
- Java
- Title
- java method
- Category
- Java
- Title
- how to get individual words from a string in java
- Category
- Java
- Title
- how to add to a file in java
- Category
- Java
- Title
- processing audio android
- Category
- Java
- Title
- how to make a loop in java
- Category
- Java
- Title
- eliminar el primer caracter de un string java
- Category
- Java
- Title
- java program to get all cat indices in elasticsearch javadoc
- Category
- Java
- Title
- java map example
- Category
- Java
- Title
- in javascipt how to stop further page processing
- Category
- Java
- Title
- java sort array descending
- Category
- Java
- Title
- get day name from date in java
- Category
- Java
- Title
- java hash password
- Category
- Java
- Title
- run static method java
- Category
- Java
- Title
- Java array hashcode
- Category
- Java
- Title
- how to skip a line in java
- Category
- Java
- Title
- how to create a linked list in java
- Category
- Java
- Title
- java Convert a string IPv4 IP address to the equivalent long numeric value.
- Category
- Java
- Title
- java override equals and hashcode
- Category
- Java
- Title
- add in list java
- Category
- Java
- Title
- android studio keep device awake
- Category
- Java
- Title
- binary string to int java
- Category
- Java
- Title
- how to make a char uppercase in java
- Category
- Java
- Title
- java parse json
- Category
- Java
- Title
- a recursive function that calculates the greatest common divisor from user's input in java
- Category
- Java
- Title
- java repository sql find not in list
- Category
- Java
- Title
- run spring boot application command line
- Category
- Java
- Title
- java how to initialize an array
- Category
- Java
- Title
- get today date in java 8
- Category
- Java
- Title
- java pass arraylist by value
- Category
- Java
- Title
- how to crate a list in java script
- Category
- Java