take string 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 random number
- close searchview android java
- processing pi
- android recyclerview show hide item with animation with default animation
- java public private key encryption
- java clear bufffer to take next string inpuit
- Please ensure that your JAVA_HOME points to a valid Java SDK. You are currently pointing to: /usr/lib/jvm/java-13-oracle
- convert from integer to character java
- boolean parse jtextfield
- spigot repeating task
- make recycler view non scrollable
- java stack push
- how to find the divisors of a number in java
- list in java
- how to create an abstract class in java
- online money transfer andhra bank
- java http interceptor
- java how to compare strings
- primitive and non primitive data types in java
- java 8 random string generator
- how to create an array list in java
- java null pointer exception
- java get icon for file type
- string startswith java