James Yeoman James Yeoman - 1 month ago 9
Java Question

Is there a Java built-in construct like vb.net's Do Until Loop?

I am trying to make my code more readable and so it would be useful to use the following (or equivalent)

do
{
...
}
until(Display.isCloseRequested())


rather than

do
{
...
}
while(!Display.isCloseRequested())


but I can't seem to find something like this.

Yes, I don't like the 'java convention' of having the opening brace on the same line as the statement and the final statement on the same line as the closing brace. I prefer that code style.

Answer

No, Java doesn't have a do-until loop construct or similar. Just do-while with the opposite test as you indicated in the question, for, and while. All use "positive" tests (loop continues while test is true).

More in the JLS: