Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

prendere valore da tastiera 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 :: how to implement linked list in java without using collection framework 
Java :: java uuid from string 
Java :: how to check if location is enabled android 
Java :: android studio edittext text change listener 
Java :: java remove file extension from file name 
Java :: android studio visibility 
Java :: padding a string with 0 in java 
Java :: gradle fatjar 
Java :: javafx file to image 
Java :: array slice java 
Java :: android gridlayout equal column width 
Java :: read a file in java and store as integer array using buffered reader 
Java :: new hashmap java 
Java :: Recompile with -Xlint:deprecation 
Java :: system.out.println 
Java :: java getdeclaredfield private field 
Java :: java list addAll stream() filtereted 
Java :: bouble to bytes[] java 
Java :: java cartesian to polar 
Java :: java popup message 
Java :: how to restart activity in android 
Java :: list to lowercase java 
Java :: androidx.fragment.app.Fragment$InstantiationException 
Java :: open a new activity on click of a button 
Java :: java how to center window 
Java :: how to create textview programmatically in android 
Java :: system.out.write in java example 
Java :: how to set landscape in android studio 
Java :: how to start activity in adapter android 
Java :: input date in java 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =