C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

How to use Scanner class in java?

+1 vote
4,219 views
asked May 14, 2014 by augustaina Sr Member (4,820 points)

1 Answer

0 votes
This class is introduce java 1.5 version and it can be used to Read the contents from a resource.

import java.io.*;

import java.util.*;

class Read{

public static void main(String[] args) throws IOException{

Scanner s = new Scanner(System.in);

System.out.println(“Enter your age:”);

String str = s.nextLine();

Int age = Integer.parseInt(str);

System.out.println(“Age:” + age);

            }

}
answered May 14, 2014 by rock Expert (14,990 points)

Related questions

0 votes
1 answer 21 views
21 views asked Apr 25, 2014 by sunny Expert (11,410 points)
0 votes
1 answer 21 views
21 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 51 views
51 views asked Apr 25, 2014 by taye Sr Member (4,970 points)
0 votes
1 answer 34 views
34 views asked Feb 6, 2014 by sara Guru (24,570 points)
0 votes
1 answer 51 views
51 views asked Jan 9, 2014 by sara Guru (24,570 points)
...