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 4 of 4

Thread: My compiler says there's something wrong with 2 statements

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    62
    Thanks
    12
    Thanked 4 Times in 4 Posts

    Default My compiler says there's something wrong with 2 statements

    It so happens that my compiler is telling me there is something wrong with the 2 bottom statements of this do-while loop, just above the while-part.

    My ideas for solving this are to either eliminate the statements or just know what is wrong with the statements themselves by recognizing their nature, but I somehow can't find what each nature is.

    Here are their relevant error-messages:

     


    ReadNEditFile.java:67: error: not a statement
    String continue = keys.nextLine();
    ^
    ReadNEditFile.java:67: error: ';' expected
    String continue = keys.nextLine();
    ^
    ReadNEditFile.java:67: error: ';' expected
    String continue = keys.nextLine();
    ^
    ReadNEditFile.java:68: error: illegal start of expression
    char editOrNot = continue.charAt(0);
    ^
    ReadNEditFile.java:68: error: illegal start of expression
    char editOrNot = continue.charAt(0);
    ^
    ReadNEditFile.java:68: error: ';' expected
    char editOrNot = continue.charAt(0);
    ^
    6 errors





    This thread also comes with the problematic-code:

              do
              {
                   // Get the entry-number that the user wants to edit.
                   System.out.println("What is the number you want to add onto the account list");
                   System.out.println("starting with account-0?");
                   userNum = keys.nextInt();
     
                   // Now find it to show it to the user.
                   byteNum = ENTRY_SIZE * userNum;
                   readNEdit.seek(byteNum);
                   numFound = readNEdit.readDouble();
                   System.out.println(numFound);
     
                   // Now replace the entry with the user's new-number.
                   System.out.println();
                   System.out.println("What do you want to write over this entry?");
                   newNum = keys.nextDouble();
                   readNEdit.seek(byteNum);
                   readNEdit.writeDouble(newNum);
     
                   // Ask the user if he/she wants to continue this.
                   System.out.println("Do you want to continue editing?");
                   String continue = keys.nextLine();
                   char editOrNot = continue.charAt(0);
     
              }while (editOrNot == 'y');

    How do I correct this if the compiler seems to point out errors that aren't there?


  2. #2
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: My compiler says there's something wrong with 2 statements

    Hi,
    Can you please your source code once? May be there are extra characters typed before the line 67 and they are not visible in the screenshot you gave.
    Using Home and End keys check every line if there are extra characters hidden somewhere.

    Thanks,
    Syed.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,765
    My Mood
    Mellow
    Thanks
    234
    Thanked 712 Times in 698 Posts

    Default Re: My compiler says there's something wrong with 2 statements

    'continue' is a reserved Java keyword and cannot be used as a variable name.

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

    SOG (July 26th, 2013)

  5. #4
    Member
    Join Date
    Jul 2011
    Posts
    62
    Thanks
    12
    Thanked 4 Times in 4 Posts

    Default Re: My compiler says there's something wrong with 2 statements

    I noticed that my compiler said nothing was wrong with my debugged program thanks to knowing continue is a keyword. Thanks for the help.

Similar Threads

  1. compiler
    By olfat in forum The Cafe
    Replies: 10
    Last Post: March 8th, 2013, 12:06 AM
  2. compiler
    By olfat in forum The Cafe
    Replies: 1
    Last Post: February 22nd, 2013, 02:18 PM
  3. compiler
    By olfat in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 22nd, 2013, 01:25 PM
  4. not sure what im doing wrong with these if else statements
    By yrvd86 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 26th, 2010, 08:32 PM
  5. sql compiler
    By tsuki in forum JDBC & Databases
    Replies: 6
    Last Post: October 16th, 2009, 10:35 PM