take a value from keyboard java
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner scan= new Scanner(System.in);
//For string
String text= scan.nextLine();
System.out.println(text);
//for int
int num= scan.nextInt();
System.out.println(num);
}
/*Is better to create another instance of Scanner if you have to use both nextline
and nextInt because they can conflict each other
*/
}
Also in Java:
- java bigdecimal compareto
- java uuid
- java hashmap put
- how to get individual words from a string in java
- determine if a given binary tree is a valid bst
- how to make a searchable list in java
- java string to double
- faire un timer en java
- java script print date in YYYY-MM-DD HH:MM:SS format
- spark write partitionby
- islowercase java
- java check if file exists
- how to create an abstract class in java
- java valeur absolue
- check last character of string java
- java syntax
- arrays.fill java
- java get current date without time
- how to play a clip of audio in java when needed
- isnumber java
- how to take binary input in java
- fibonacci sequence in java recursion
- get first 5 characters of string java
- gson parse json