Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java read a line of input

// Java program to demonstrate working of Scanner in Java
import java.util.Scanner;
 
class GetInputFromUser {
    public static void main(String args[])
    {
        // Using Scanner for Getting Input from User
        Scanner in = new Scanner(System.in);
 
        String s = in.nextLine();
        System.out.println("You entered string " + s);
 
        int a = in.nextInt();
        System.out.println("You entered integer " + a);
 
        float b = in.nextFloat();
        System.out.println("You entered float " + b);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: measure running time of a statement java 
Java :: clone array in java 
Java :: spinner get selected index 
Java :: main method 
Java :: abstract class in java 
Java :: print list of map java 
Java :: Java Insert Elements to HashSet 
Java :: charat(0).touppercase() java 
Java :: fill two dimensional array column by column java 
Java :: List into string java 
Java :: how to get the max value of an array java 
Java :: for each loop java string array 
Java :: java mongodb find with multiple conditions 
Java :: integer.tostring java 
Java :: sort list java 8 
Java :: flutter java.lang.RuntimeException: Unable to instantiate activity ComponentInfo 
Java :: change color of drawable android studio 
Java :: cmd java compile 
Java :: statusbar text color android 
Java :: how to find length of array in java 
Java :: java formatted output 
Java :: programmatically click button javafx 
Java :: initialize hashmap with values 
Java :: how to round double to 2 decimal places java 
Java :: linkedhashmap in java 
Java :: android menu change text color 
Java :: esponente in java 
Java :: Java printf() Method using PrintWriter 
Java :: java android development get element by id 
Java :: How do you count characters in a string array in Java? 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =