Java program of taking Input.


Today we are going to learn to take input in Java.

import java.lang.*

class Solution


public static void main(String arg[])


Scanner sc = new Scanner (;

String a =sc.nextLine();

int b =sc.nextInt();

Double d = sc.nextDouble();

System.out.println(“Value of String is :”+a);

System.out.println(“Value of Integer is:”+b);

System.out.println(“Value of Double is:”+d);


So in the Above program we take input in Java using the Scanner Class Utility.

Inorder to take input for various Datatype we need to use scanner object as

For Integer :


For Double:


For Boolean:


For String

nextLine() or Simply next()

Compile the program and see the output


First Post

Hi Guys, this blog is develop to help people to learn java. From now on wards there will be a series of programs / post explaining various java concepts .