How to use scanner in java?



How to use scanner in java?..

Answer / 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

More Core Java Interview Questions

Why parameters should be passed by reference?

0 Answers  


Adapter classes?

3 Answers  


What is the purpose of finalization?

4 Answers  


How do you break a loop?

0 Answers  


What is hash table in java?

0 Answers  


What is the immediate parent class of the Applet class?

1 Answers  


Name the method that used to clear the buffer ?

2 Answers  


How to handle a web browser resize operation?

0 Answers  


How to call static method?

4 Answers   Epoch,


what is the difference between statis block and static variable

7 Answers  


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

0 Answers  


Can we clone singleton class in java?

0 Answers  


Categories