Java syntax: Difference between revisions

Content deleted Content added
 
(2 intermediate revisions by the same user not shown)
Line 476:
/* The following line is equivalent to
if (foo == ColorName.RED) foo = ColorName.BLUE; */
if (foo == RED) {
foo = BLUE;
}
}
}
Line 722 ⟶ 724:
 
===Iteration statements===
Iteration statements are statements that are repeatedly executed when a given condition is evaluated as true. Since [[J2SE 5.0]], Java has four forms of such statements. The condition must have type <code>boolean</code> or <code>java.lang.Boolean</code>. Java does not implicitly convert integers or class types to Boolean values.
 
For example, the following code is valid in C but results in a compilation error in Java.
Line 786 ⟶ 788:
 
====Labels====
Labels are given points in code used by <code>break</code> and <code>continue</code> statements. The JavaWhile <code>goto</code> is a reserved keyword in Java, it cannot be used to jump to specific points in code (in fact it has no use at all).
 
<syntaxhighlight lang="java">