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 ellipsis in java?

830


What are different access specifiers in java?

770


What is a parameter in a function?

769


What is thread life cycle in java?

834


What modifiers are allowed for methods in an interface?

901


What is the difference between I ++ and ++ I in java?

757


What is difference between ++ I and I ++ in java?

737


What is a predicate method?

774


Java is Pass by Value or Pass by Reference?

824


What is prefix of a string?

815


What are new features introduced with java 8 ?

753


What is a copy constructor in java?

833


What is string syntax?

839


Can a string be null?

760


What is a functional interface?

778