13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.2 Fundamental Language Elements65permissi<strong>on</strong> in that directory (check the permissi<strong>on</strong>s with ls -ld .) then youcan run these commands:$ cd /usr/local/java$ unzip -q /tmp/j2sdk-1_4_2-doc.zipThere may be quite a pause (tens of sec<strong>on</strong>ds) while it unzips everything.The unzip command will spew out a huge list of filenames as it unpacks themunless you use the -q opti<strong>on</strong> (“quiet”) <strong>on</strong> the command line (which we did, toavoid all that). The files are all unzipped into a directory named docs. So nowyou can point your browser tofile:///usr/local/java/docs/api/index.htmlNow you have your own local copy for quick reference, regardless of howbusy the network or Sun’s Web site gets. Be sure to bookmark this page; you’llwant to reference it often. It’s your best source of informati<strong>on</strong> about all thestandard Java2 classes.3.2.3 StatementsThis secti<strong>on</strong> is not intended to be a formal presentati<strong>on</strong> of Java syntacticelements. 3 Our purpose here is merely to show you the Java way to expresscomm<strong>on</strong> programming c<strong>on</strong>structs. You will find that these are fundamentallysimilar to the analogous statements in C and C++. For much more detail <strong>on</strong>these subjects, see Chapter 3 of Thinking in Java by Bruce Eckel.Like C, Java has a very small set of statements. Most c<strong>on</strong>structs are actuallyexpressi<strong>on</strong>s. Most operati<strong>on</strong>s are either assignments or method calls. Those fewstatements that are not expressi<strong>on</strong>s fall into two broad categories:• C<strong>on</strong>diti<strong>on</strong>al executi<strong>on</strong> statements• Loop c<strong>on</strong>trol statementsBy the way, you may have already noticed <strong>on</strong>e of the two kinds ofcomments that Java supports. They are like the C/C++ comments—a pair ofslashes (//) marks a comment from there to the end of the line, and a block3. For those so inclined, Sun has a BNF language grammar (http://java.sun.com/docs/books/jls/sec<strong>on</strong>d_editi<strong>on</strong>/html/syntax.doc.html) <strong>on</strong> their Web site, and the Lewis andLoftus book, Appendix L, has a good set of syntax diagrams.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!