Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: What exactly is the purpose of a Scanner class?

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Location
    New Brunswick, Canada
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default What exactly is the purpose of a Scanner class?

    I was reading Java Software Solutions-7th edition and found about the scanner class, however their description doesn't really help me understand the purpose of the Scanner class. So, where is Scanner classes usually used in and what is the purpose of the Scanner?


  2. #2
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: What exactly is the purpose of a Scanner class?


  3. #3
    Junior Member
    Join Date
    Apr 2014
    Location
    New Brunswick, Canada
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: What exactly is the purpose of a Scanner class?

    so is it scanner basically
     BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
    String firstPlayer, secondPlayer;
    is it same as BufferedReader?

  4. #4
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: What exactly is the purpose of a Scanner class?

    read this for scanner - Scanner (Java Platform SE 7 )
    for bufferedread - BufferedReader (Java Platform SE 7 )

    not actually same, there are some methods of scanner that is also the same with some methods in BufferedReader, but the two classes are not the same.

    As what says by Scanner doc, scanner is capable of parsing tokens from the content of the stream
    BufferedReader just read the stream but not capable of any special parsing

    you can also read this link - Java: Difference Between Scanner Method & Buffered Reader, Scanner, BufferedReader

  5. The Following User Says Thank You to dicdic For This Useful Post:

    ekrocks (April 10th, 2014)

  6. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: What exactly is the purpose of a Scanner class?

    When you've done the suggested reading, take a break and do some coding to experience what the tools do. First, type every example program you found in the suggested reading, then do some exploring in code on your own to answer any questions you still have. You learn a skill and build confidence in your abilities at that skill much more by doing it, practicing, experimenting, than by reading about it.

  7. The Following User Says Thank You to GregBrannon For This Useful Post:

    ekrocks (April 10th, 2014)

Similar Threads

  1. Using the Scanner class
    By Brocco767 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 26th, 2012, 07:47 PM
  2. use Delimiter, Scanner Class
    By izzahmed in forum What's Wrong With My Code?
    Replies: 12
    Last Post: October 25th, 2011, 05:27 PM
  3. Scanner class error "java.lang.Error"
    By Lheviathan in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 21st, 2009, 02:23 AM
  4. [SOLVED] Problem in Coin-counter with scanner class
    By coccoster in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: March 25th, 2009, 08:46 AM
  5. Replies: 1
    Last Post: May 13th, 2008, 08:08 AM