O'Reilly logo

C# for Java Developers by Adam Freeman, Allen Jones

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Statements

Extensive commonality exists in the syntax and functionality of statements in C# and Java:

  • All statements must end with a semicolon.

  • Block statements are formed using braces.

  • An empty statement is represented by a single semicolon. In both languages, it’s considered a good idea to comment the existence of any empty statement.

Labeled Statements

Labeled statements are implemented by C# and Java in the same way, differing only in how jumps are performed. In Java, jumps are made to a labeled statement using the continue or break statement, as shown in the following example:

mylabel:
// statements
while (/* some condition */) {
    break mylabel;
}

In C#, the break and continue statements do not take targets. To jump to a labeled statement, use the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required