Content deleted Content added
(3 intermediate revisions by the same user not shown) | |||
Line 513:
==Operators==
Operators in Java are similar to those in [[C++]]. However, there is no <code>delete</code> operator due to [[Garbage collection (computer science)|garbage collection]] mechanisms in Java, and there are no operations on [[Pointer (computer programming)|pointers]] since Java does not support them. Another difference is that Java has an unsigned right shift operator (<code>>>></code>), while C's right shift operator's signedness is type-dependent. Operators in Java cannot be [[Operator overloading|overloaded]]. The only overloaded operator is <code>operator+</code> for string concatenation.
{| class="wikitable"
Line 722:
===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
For example, the following code is valid in C but results in a compilation error in Java.
<syntaxhighlight lang="c">
while (1) {
doSomething();
}
</syntaxhighlight>
====<code>while</code> loop====
Line 763 ⟶ 766:
</syntaxhighlight>
Like C, all three expressions are optional. The following loop
<syntaxhighlight lang="java">
for (;;) {
Line 770 ⟶ 773:
</syntaxhighlight>
====
{{Main|
[[
<syntaxhighlight lang="java">
|