Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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
  */
  
}
Comment

PREVIOUS NEXT
Code Example
Java :: java selenium wait 
Java :: moving text in textview android 
Java :: How do you print duplicate characters from a string? 
Java :: how to convert object to list in java 
Java :: jbutton remove selection border 
Java :: string array to arraylist android 
Java :: how to install java 11 jdk on ubuntu 20.04 
Java :: HTTP FAILED: java.net.UnknownServiceException: CLEARTEXT communication to ztdev.co.za not permitted by network security policy 
Java :: set location of a label java 
Java :: ova definition 
Java :: Spigot API inventory close 
Java :: javaee jsp convert int to string 
Java :: java remove first element from array 
Java :: round bg android 
Java :: read file using scanner in java 
Java :: jakkala siva venkata deepesh 
Java :: java mouselistener get coordinates 
Java :: Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x); 
Java :: appcompatdelegate.setdefaultnightmode(appcompatdelegate.mode_night_yes) not working 
Java :: plus one leetcode java 
Java :: rwegex java 
Java :: access each key and value in a hashmap java 
Java :: java key pressed 
Java :: java swing stripes 
Java :: entryset in java loop 
Java :: cors filter spring boot 
Java :: collect as arr java 8 
Java :: set precision in java 
Java :: how to change top of window in java 
Java :: java get longest string in array 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =