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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.