• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can someone please explain why does the 'FOR' loop run 32 times int the ' public void displayTree()'  RSS feed

 
Vatsa Joshi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

>
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you told it to run 32 times?

For some reason you have used 32 for the variable emptyLeaf and then told the loop to run that many times. I don't know why you wrote 32.
Don't use == false or == true or similar. That is poor style and very error‑prone; what if you write = instead, as we have seen here often enough.
Use if (b)... or if (!b)..

Welcome to the Ranch I have added code tags, which you should always use, to your code and you can see how much better it looks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!