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

Thread: Error when loop used

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error when loop used

    int choice;
    		System.out.println ("type 1 to add, 2 to display, 3 to delete, 4 to exit");
    		choice=input.nextInt();
    		while(choice!=4)
    		{
    		if(choice==2)	
    		rfile.displayAll();
    		if(choice==3)
    		rfile.deleteRecord();
    		System.out.println ("type 1 to add, 2 to display, 3 to delete, 5 to exit");
    		choice=input.nextInt();

    I keep getting run time erroe when I select option 3 and use the while loop
    but if i call the delete method directly its fine
    Why is that?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Error when loop used

    What error are you getting? Please post the full error message.

    Likely though, you're mixing parenthesis and brackets, and you're while loop doesn't have a closing bracket.

Similar Threads

  1. help with a for loop
    By newbie79 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 3rd, 2010, 02:20 AM
  2. [SOLVED] logic error: cpu assigning incorrect values in for loop
    By Perd1t1on in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 25th, 2010, 08:13 PM
  3. for loop and while loop problems
    By Pulse_Irl in forum Loops & Control Statements
    Replies: 4
    Last Post: May 3rd, 2010, 02:09 AM
  4. hi. i want to rewrite this do loop into a while loop.
    By etidd in forum Loops & Control Statements
    Replies: 3
    Last Post: January 26th, 2010, 04:27 PM
  5. Need help with loop
    By SwEeTAcTioN in forum Loops & Control Statements
    Replies: 8
    Last Post: October 25th, 2009, 05:59 PM