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 :: java solid principles 
Java :: formatting an integer in java 
Java :: java booleans 
Java :: how to find the size of a queue in java 
Java :: get length of a string java 
Java :: java math power 
Java :: how to find some of digits in java 
Java :: java string to uuid 
Java :: java string not equal 
Java :: 123 movies 
Java :: list of numbers java 
Java :: current time in long java 
Java :: how to change actionbar color in android programmatically 
Java :: all installed java 
Java :: java priority queue 
Java :: big java 2010 heaptree java program 
Java :: how to clear text fields in java 
Java :: override onbackpressed in fragment 
Java :: java reverse string 
Java :: java code for square 
Java :: gat environment variables java 
Java :: calculate smallest angle difference 
Java :: array contain java 
Java :: convert integer array to string array 
Java :: file java class 
Java :: java add element to existing array 
Java :: java extends 
Java :: java arraylist add 
Java :: fastreader in java 
Java :: not equal java 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =