read int 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:
- processing play sound
- how to set a variable java
- diagonal difference hackerrank solution in java 8 using list
- ujava saum of positive integers
- open an existing excel file in java apache poi
- how to compare strings java
- JOptionPane with drop down list java
- android studio remove notification bar
- function in java
- substring java
- how-to-use-volley-string-request-in-android
- throwing exceptions java
- print in one line in java
- android get sdk version
- how to change the icon of a jframe
- java loop through arraylist
- java stack methods
- arraylist to int array java
- add two numbers bitwise
- java indexof array
- how to take max value from priority queue in java
- copy array in java
- Java int to roman
- how to make an array in java