1 Replies - 174 Views - Last Post: 22 November 2011 - 01:15 PM Rate Topic: -----

#1 awh3371  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 17-November 11

Infinite loops

Posted 22 November 2011 - 01:06 PM

I got my program to loop 10 times.
Just trying to find the code for the infinite loop.
Looked all over the web but kept getting inconsistent solutions.
Any help would be great!

int i;
for (i=1; i<=10; i++){//loop 10 times
while(wrong1<1){
name = JOptionPane.showInputDialog(null, "Please enter the name in the correct format FirstName, LastName:");
final int commaPlace=name.indexOf(',');
if(commaPlace<=0){
	JOptionPane.showMessageDialog(null,"Please enter the name in the correct format FirstName, LastName:");
wrong1=0;}
else wrong1++;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Infinite loops

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4334
  • View blog
  • Posts: 12,128
  • Joined: 18-April 07

Re: Infinite loops

Posted 22 November 2011 - 01:15 PM

Want an infinite loop? Not sure why, but all you need is...

while(true) {
   // Stuff in here
}



Enjoy! I think... ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1