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

write a progam hashmap & hashtable?

2 Answers   IBM,


What is consumer interface?

0 Answers  


Write an algorithm for quick sort?

0 Answers   Virtusa,


where the static methods will live ,on stack ? can you explain brefly

1 Answers  


Can an integer be null java?

0 Answers  






ublic class Java_Coding_Samples { public static void JavaHungr(NumberFormatException ae){ System.out.println("integer"); } public static void JavaHungry(Exception e){ System.out.println("string"); } public static void JavaHungry(ArithmeticException ae){ System.out.println("object"); } public static void main(String[] args) { JavaHungry(null); }

1 Answers  


What is merge sort in java?

0 Answers  


Explain method overloading and overriding?

6 Answers  


What is the major advantage of external iteration over internal iteration?

0 Answers  


My application URL : http://localhost:8080/Application/Login.jsp. When a user enter this url in IE then, how it get Login.JSP Page exactly? what are the processes will happen from when we submit the URL to get Login.jsp?

3 Answers   IBM, TCS,


What is collection api?

0 Answers  


Is Constructor possible in abstract class in java ?

0 Answers   HCL,


Categories