Conventions Used in This Book

Body text is Times Roman, normal, like you’re reading now.

A Constant width font is used for:

  • Code examples and fragments

  • Keywords, operators, data types, variable names, class names, and interface names that might appear in a Java program

  • Program output

  • Tags that might appear in an HTML document

A bold constant width is used for:

  • Command lines and options that should be typed verbatim on the screen

An italicized constant width font is used for:

  • Replaceable or variable code fragments

An italicized font is used for:

  • New terms where they are defined

  • Pathnames, filenames, and program names. (However, if the program name is also the name of a Java class, it is given in a monospaced font, like other class names.)

  • Host and domain names (java.oreilly.com)

  • Titles of other books (Java I/O)

Significant code fragments and complete programs are generally placed in a separate paragraph like this:

Socket s = new Socket("java.oreilly.com", 80);
if (!s.getTcpNoDelay(  )) s.setTcpNoDelay(true);

When code is presented as fragments rather than complete programs, the existence of the appropriate import statements should be inferred. For example, in the previous code fragment you may assume that java.net.Socket was imported.

Some examples intermix user input with program output. In these cases, the user input will be displayed in bold, as in this example from Chapter 10:

% telnet localhost 7
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
This is a test
This is a test
This is another test
This is another test
9876543210
9876543210
^]
telnet> close
Connection closed.

The Java programming language is case-sensitive. Java.net.socket is not the same thing as java.net.Socket. Case-sensitive programming languages do not always allow authors to adhere to standard English grammar. Most of the time, it’s possible to rewrite the sentence in such a way that the two do not conflict, and when possible, I have endeavored to do so. However, on those rare occasions when there is simply no way around the problem, I have let standard English come up the loser. In keeping with this principle, when I want to refer to a class or an instance of a class in body text, I use the capitalization that you’d see in source code, generally an initial capital with internal capitalization—for example, ServerSocket.

Throughout this book, I use the British convention of placing punctuation inside quotation marks only when punctuation is part of the material quoted. Although I learned grammar under the American rules, the British system has always seemed far more logical to me, even more so than usual when one must quote source code where a missing or added comma, period, or semicolon can make the difference between code that compiles and code that doesn’t.

Finally, although many of the examples used here are toy examples unlikely to be reused, a few of the classes I develop have real value. Please feel free to reuse them or any parts of them in your own code. No special permission is required. As far as I am concerned, they are in the public domain (though the same is most definitely not true of the explanatory text!). Such classes are placed somewhere in the com.macfaq package, generally mirroring the java package hierarchy. For instance, Chapter 4’s SafePrintWriter class is in the com.macfaq.io package. When working with these classes, don’t forget that the compiled .class files must reside in directories matching their package structure inside your class path and that you’ll have to import them in your own classes before you can use them. The book’s web page at http://metalab.unc.edu/javafaq/books/jnp2e/ includes a jar file containing all these classes that can be installed in your class path.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.66.13