How to use scanner in java?

Answer Posted / hrindows@gmail.com

import java.util.Scanner;

class classname{
public methodname(){
//Scanner declaration
Scanner s_name = new Scanner(System.in);
//Use Scanner to take input
int val = s_name.nextInt();
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scope & storage allocation of static, local and register variables? Explain with an example.

572


Can java list contain duplicates?

576


What is meant by inheritance and what are its advantages?

583


What are the core java topics?

569


Is class is a data type?

574






Define interface in java?

609


What two classes are used to read data only?

645


What is use of functional interface in java 8? Explain

567


Can we override private methods?

549


What is executor memory?

527


What is the size of an array?

553


Enlist diffrent types of inheritance supported by java?

489


Write a java program for binary search?

611


What is the difference between JDK and JVM?

635


Where is singleton pattern used?

532