This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes While-loop , can't BREAK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "While-loop , can Watch "While-loop , can New topic

While-loop , can't BREAK

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I am doing a List filter. for example, in the coding below, I am trying to filter the people whose age is 30.

But it can NOT jump out the while-loop, when it should break. I don't know why ? THe coding is complete, you could test it.

Thanks for your help.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

You're looping in two different ways: the "while true" loop, and a recursive call to the same routine. The recursive call is unnecessary; after modifying the list, you can just let the loop go again.

[Jess in Action][AskingGoodQuestions]
Have you checked out Aspose?
subject: While-loop , can't BREAK
It's not a secret anymore!