Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

6. Using the Scanner Class in Java (Complex)

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
5,339
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jun 29, 2009

Watch in HD for better viewing.

Learn to take information from the user and use the information in your programming. This program is the second iteration of my print name program. It uses two classes and a method. By watching this, you are taking the first step in understanding object oriented programming.

Code:

import java.util.Scanner;

class GetInformation {

public static void main(String args[]) {
GetName newGetName = new GetName();
newGetName.doWork();

}

}

class GetName {

Scanner myScanner = new Scanner(System.in);
String input;

void doWork() {

System.out.println("Enter your name please: ");
input=myScanner.nextLine();

System.out.println("Your name is: " + input);

}

}

Please check out my other vids for more tutorials. Also, please leave comments with any suggestions.
Subscribe, comment, rate.

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (javaprogrammer345)

  • Do you play WoW?

  • no... no i do not

Top Comments

  • Cool man. Thanks for posting. I am up just learning and that helped me out. ALOT. Appreciate the time you took very descriptive. I RECOMMEND THIS VIDEO TO EVERYBODY learning JAVA.

see all

All Comments (7)

Sign In or Sign Up now to post a comment!
  • import java.util.Scanner;

    Thank you so much.

  • I hate to tell you man, but this is not a complex use of the Scanner class. You don't even cover the handling of Exceptions as you should.

  • Such a long code for such a small task. In C++ is much easier and shorter, althought it's not as portable as Java :( Ayway, very nice tutorial :D Subscribed !

  • Excellent vid...very helpful...

  • Excelente trabajo. Me ayudo muchisimo.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more