File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 24199

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]
I agree. Here's the link:
subject: While-loop , can't BREAK
It's not a secret anymore!