• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Can anyone tell me while this loop doesn't finish looping?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


this loop should run twice and it only runs once. It seems to freeze. I threw a couple printlns in there for testing. The "Testmids Finished" line never prints so somewhere in the loop its freezing. I also checked to see if the freeze is happening in any other methods that are being called by this method and that is not the case. The problem is in this method and I can't figure it out for the life of me. The top loop, is

fullTable = 4
so the loop should run for j =2 and j = 3 then stop. It only runs for j = 2 that nothing happens, the program doesn't finish. There are no run time errors either. Any ideas?
(Also if anyone see's any suggestions on how to make this code nicer please let me know as I have no idea what I'm doing :] ) I am copying arrays all the time which seems like such a waste. When I pass these arrays to other methods, they modify the array and I need the original value so I need to make copies of arraylists over and over. Is there a way to avoid this? My main question is why is this program freezing though. THanks
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try printing ad.getLeftAndRightCols().size() inside the second (inner) loop.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println() is your best friend. stick them in all over the place. I frequently put them in as the first and last line in each loop body, printing the conditional variable to see if it is changing how I think it should. you can start narrowing down where the problem is and remove the ones you don't care about, and then stick in more to isolate the problem.
 
Joseph Tulowiecki
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
was an endless while loop in another method. I thought it wasnt in another method but i was wrong. narrowed it down with a million system.out.println's thanks all !!
 
The City calls upon her steadfast protectors. Now for a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic