8.1. Rules of Syntax

As you start writing real-world programs and try to decipher cryptic error messages from your compiler, it is nice to know the rules of the game. This short section describes some of the lexical and grammatical rules in Java.

Careful use of descriptive comments, white space, and indentation can make your source code easier to read. Two types of comments are permitted: block style and line style. Block-style comments are contained between /* (slash-star) and */ (star-slash) tokens; they can span multiple lines and are sometimes used to quickly comment-out a large block of code during testing. Line-style comments begin with two slashes, //; these comments extend just until the end of the line of code.

White space refers to ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.