| | |
Breaking out of a Loop
![]() |
•
•
Join Date: Mar 2004
Posts: 6
Reputation:
Solved Threads: 0
I need help with breaking out of a loop. I know it's something simple, but I can't remember. Here's my code.
for(count = 0; count < inputArray.length; count++)
{
inputArray[count] = JOptionPane.showInputDialog(
null,
"Please input a name or exit: ",
"Input Name",
JOptionPane.QUESTION_MESSAGE);
if(inputArray[count] == "Exit")
{
break;
}
}
for(count = 0; count < inputArray.length; count++)
{
inputArray[count] = JOptionPane.showInputDialog(
null,
"Please input a name or exit: ",
"Input Name",
JOptionPane.QUESTION_MESSAGE);
if(inputArray[count] == "Exit")
{
break;
}
}
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I don't think you can use the break statement in for loops. I guess you would have to set the count variable to something greater than the ending condition in the loop, that way it won't loop anymore.
or something like that;
Java Syntax (Toggle Plain Text)
for int(i=0; i<10; i++) { if (i=2) { i = 11; } }
![]() |
Similar Threads
- Breaking out of Loop Java (Java)
- End a for loop (C++)
- breaking out of multiple loops (C)
- Halp in breaking a loop (C++)
Other Threads in the Java Forum
- Previous Thread: Help! Scanning through each image pixel...
- Next Thread: passing arrays to classes?
| Thread Tools | Search this Thread |
6 @param actuate android api applet application arc array arrays automation balls binary bluetooth bold business byte c++ chat class client code codesnippet collections compare component coordinates database defaultmethod detection doctype dragging ebook eclipse educational error file fractal froglogic game givemetehcodez graphics gui guitesting helpwithhomework hql html ide ideas image ingres input integer internet intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans newbie nextline parameter php pong problem program programming project recursion recursive scanner sell server set sms sort sql string sun swing swt terminal threads tree web websites windows






