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 Stuck again on the Loops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Stuck again on the Loops" Watch "Stuck again on the Loops" New topic

Stuck again on the Loops

Fitz Herbert

Joined: Mar 22, 2003
Posts: 21
When a loop will definitely not run due to an argument of false say ? is any compilation errors thrown
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
Do you have some sample code as an example of what you're asking?
It's easier to help you with concrete code examples to talk about.

SCJP 1.4
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

For loops, you will get an "Unreachable statement" compilation error if you use the false literal

If statements (which aren't loops) do accept the literal false as an argument:

Both of these will compile; this is used to mimic C/C++'s conditional compilation:

[ May 29, 2003: Message edited by: Joel McNary ]

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Sometimes yes, sometimes no. Take a look at this thread for a discussion on the subject.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: Stuck again on the Loops
It's not a secret anymore!