Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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

PREVIOUS NEXT
Code Example
Java :: reload zsh profile 
Java :: localdatetime to xmlgregoriancalendar 
Java :: how to check type of primitive value in java 
Java :: java yesterday date 
Java :: how to vibrate android java 
Java :: jsoup android 
Java :: cannot lock java compile cache as it has already been locked by this process 
Java :: java string join arraylist 
Java :: java jackson cast to list 
Java :: how to load font in java 
Java :: update value in hashmap java 
Java :: java import decimalformat 
Java :: format localdate java 
Java :: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade java.lang.OutOfMemoryError (no error message) 
Java :: bukkit give player effect 
Java :: Which activity lifecycle method will call in Following Scenario - Launch ActivityA - Press Device Home Button - Again Launch Application * 
Java :: running time of java program 
Java :: shakescleare merchant of venice 
Java :: intent android open activity 
Java :: spring config.xml file 
Java :: how to write custom message for repeat password in joi 
Java :: how to find length of set in java 
Java :: rdd. map with condition 
Java :: taking string input in java 
Java :: change material fab color android 
Java :: Date from String java11 
Java :: java get unix timestamp 
Java :: java connect mariadb 
Java :: Duplicate class org.intellij.lang.annotations. 
Java :: Convert c# to xml string 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =