Professional Documents
Culture Documents
4
JAVA: Scanner Class
1
Today’s Topics
• Taking input using Scanner class
• Some exercises using scanner class
Taking input from User
Scanner Class
• ‘Scanner’ class is used to take input from user
• Take some information about yourself (i.e. name, age, cgpa, department,
section etc) as input and display them.
1.import java.util.*;
2.public class ScannerExample {
3.public static void main(String args[]){
4. Scanner in = new Scanner(System.in);
5. System.out.print("Enter your name: ");
6. String name = in.nextLine();
7. System.out.println("Name is: " + name);
8. }
9. }
Thank You