Results 1 to 3 of 3
  1. #1
    Teclis is offline Member
    Join Date
    Mar 2011
    Posts
    48
    Rep Power
    0

    Default Reading characters into a string

    I am wanting to enter the name "Smith" into String name.
    Java Code:
    while(counter <= 3)
    {
       name = in.next();
       wages = scan.nextDouble();
       hoursWorked = scan.nextDouble();

    I keep getting the error:
    Lab8.java:41: cannot find symbol
    symbol : variable in
    location: class Lab8
    name = in.next();
    ^

    With the carrot pointing at the in.
    What can/should I do?

    EDIT: I'm sorry, I didn't realize that between the text book style and my own that "in.next" in the text book is "scan.next" for me.
    Last edited by Teclis; 03-08-2011 at 08:19 PM.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Mark your thread solved with the thread tools if you are done. Also check out the scanner nextLine method.

  3. #3
    Teclis is offline Member
    Join Date
    Mar 2011
    Posts
    48
    Rep Power
    0

    Default

    I had to use scan.next() because the input I had to manipulate was "Smith 24.5 40".

Similar Threads

  1. Two '\n' characters between lines while reading File
    By subith86 in forum New To Java
    Replies: 6
    Last Post: 02-26-2011, 09:56 AM
  2. Reading Characters from a ByteBuffer
    By Dan0100 in forum New To Java
    Replies: 2
    Last Post: 09-20-2010, 10:05 PM
  3. Scanner reading accented characters
    By Phenomena in forum New To Java
    Replies: 2
    Last Post: 04-29-2010, 04:06 PM
  4. Reading characters without showing up on the screen?
    By alexsb92 in forum New To Java
    Replies: 11
    Last Post: 03-28-2010, 08:08 PM
  5. writing and reading unicode characters from a file
    By ranoosh in forum Advanced Java
    Replies: 4
    Last Post: 09-28-2008, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •