Java Reference
In-Depth Information
This type of comment cannot be nested (i.e., one /* */ comment cannot appear
within another). When writing multiline comments, programmers often use extra *
characters to make the comments stand out. Here is a typical multiline comment:
/*
* First, establish a connection to the server.
* If the connection attempt fails, quit right away.
*/
The third type of comment is a special case of the second. If a comment begins
with /** , it is regarded as a special doc comment . Like regular multiline comments,
doc comments end with */ and cannot be nested. When you write a Java class you
expect other programmers to use, use doc comments to embed documentation
about the class and each of its methods directly into the source code. A program
named javadoc extracts these comments and processes them to create online docu‐
mentation for your class. A doc comment can contain HTML tags and can use addi‐
tional syntax understood by javadoc . For example:
/**
* Upload a file to a web server.
*
* @param file The file to upload.
* @return <tt>true</tt> on success,
* <tt>false</tt> on failure.
* @author David Flanagan
*/
See Chapter 7 for more information on the doc comment syntax and Chapter 13 for
more information on the javadoc program.
Comments may appear between any tokens of a Java program, but may not appear
within a token. In particular, comments may not appear within double-quoted
string literals. A comment within a string literal simply becomes a literal part of that
string.
Reserved Words
The following words are reserved in Java (they are part of the syntax of the language
and may not be used to name variables, classes, and so forth):
abstract const final int public throw
assert continue finally interface return throws
boolean default float long short transient
break do for native static true
byte double goto new strictfp try
case else if null super void
catch enum implements package switch volatile
char extends import private synchronized while
class false instanceof protected this
We'll meet each of these reserved words again later in this topic. Some of them are
the names of primitive types and others are the names of Java statements, both of
Search WWH ::




Custom Search