Java V1.0.1 2007 4 10
1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1 12 7.2 12 7.3 12 7.4 If, if-else, if else-if else..12 7.5 for..13 7.6 while.13 7.7 do-while.13 7.8 switch (switch Statements).13 7.9 try-catch.14 8.14
8.1..14 8.2..15 9..15 10.17 10.1 17 10.2 17 10.3.17 10.4..17 10.5..18 10.6..18 10.6.1.18 10.6.2.18 10.6.3 "?".19 10.6.4 19 11 19 11.1 Java..19
1 1.1 80% 1.2 Sun MicroSystems Java http://java.sun.com/docs/codeconv/html/codeconvtoc.doc.html 2 2.1 2.2 Java Java.java Java.class MANIFEST.MF.MF XML.xml.property Jar.jar 3 11 Java
3.1 Java 2000 3.2 Java Java Java 3.2.1 C /* * Classname * * Version information * * Date * * Copyright notice */ 3.2.2 Java package java.awt; import java.awt.peer.canvaspeer; import java.awt.peer.canvaspeer; import java.awt.peer.*;
3.2.3 1. / JavaDoc /***/ 2. 3. / /**/ / 4. public protected friendly private 5. public protected friendly private 6. 7. 8. main() 9. exit() main() 4 4 eclipse TAB 4.1 80 4.2 TAB somemethod(longexpression1, longexpression2, longexpression3, longexpression4, longexpression5); // var = somemethod1(longexpression1, somemethod2(longexpression2, longexpression3)); //
longname1 = longname2 * (longname3 + longname4 - longname5) + 4 * longname6; // longname1 = longname2 * (longname3 + longname4 - longname5) + 4 * longname6; // TAB // somemethod(int anarg, Object anotherarg, String yetanotherarg, Object andstillanother) { // TAB private static synchronized horkinglongmethodname(int anarg, Object anotherarg, String yetanotherarg, Object andstillanother) { 5 Java (JavaDoc) C++ /**/ // ( doc comments ) Java /***/ JavaDoc HTML (implementation-free)
5.1 4 (block) (single-line) (trailing) (end-of-line) 5.1.1 /* * Here is a block comment. */ 5.1.2 Java if (condition) { /* Handle the condition. */ 5.1.3 Java if (2 == a) { return TRUE; /* special case */ else { return isprime(a); /* works only for odd a */
5.1.4 "//" if (foo > 1) { // Do a double-flip. else { return false; // Explain why here. //if (bar > 1) { // // // Do a triple-flip. // // //else { // return false; // 5.2 Java (field) /***/ /** * The Example class provides */ public class Example { (top-level) (/**) 1 ( ) TAB ( 5.1.1) ( 5.1.2) Java
5.3 / / / / 5.4 @param @throws @return 6 6.1 int level; // indentation level int size; // size of table int foo, fooarray[]; // 6.2 6.3 "{" ""
void mymethod() { int int1 = 0; // beginning of method block if (condition) { int int2 = 0; // beginning of "if" block for for (int i = 0; i < maxloops; i++) { int count; mymethod() { if (condition) { int count = 0; // 6.4 "(" "{" "" "{" class Sample extends Object { int ivar1; int ivar2; Sample(int i, int j) { ivar1 = i; ivar2 = j; int emptymethod() {
7 7.1 argv++; // argc--; // argv++; argc--; // 7.2 "{ " "{" "" if-else for bug 7.3 return "()" return; return mydisk.size(); return (size? size : defaultsize); // 7.4 If, if-else, if else-if else if-else if (condition) { if (condition) {
else { if (condition) { else if (condition) { else{ if "{" "" if (condition)statement; // 7.5 for for for (initialization; condition; update) { for "{" "" 7.6 while while while (condition) { while "{" "" 7.7 do-while do-while do { while (condition); 7.8 switch (switch Statements) switch switch (condition) {
case ABC: /* falls through */ case DEF: break; case XYZ: break; default: break; case ( break ) break /* falls through */ 7.9 try-catch try-catch try { catch (ExceptionClass e) { finally { 8 8.1 (section)
"5.1.1" "5.1.2" 8.2 while (true) { void method1(int a, int b) "." ("-") ("++") ("--") a += c + d; d++; for for (expr1; expr2; expr3) char c; int a = 1; c = (char) a; 9 15 persistentobj persistentobjs ansqlstmt ansqlstmt No. number ID. identification
(Packages) (Classes) (Interfaces) (Methods) (Variables) (Parameter) (Collection) (Array) (Constants) ASCII com.chinacache com.chinacache.billing com.chinacache.billing.node com.chinacache. billing.node.util class Raster; class ImageSprite; ( URL HTML) interface RasterDelegate; interface Runnable; "able" "ible" interface Accessible; run(); runfast(); getbackground(); char c; int i; float mywidth; i j k m n c d e customers orderitems postedmessages somecustomers someitems some somemessages static final int MIN_WIDTH = 4; static final int MAX_WIDTH = 999; static final int GET_THE_CPU = 1;
10 10.1 10.2 classmethod(); // AClass.classMethod(); // anobject.classmethod(); // 10.3 for -1,0 1 10.4 if (0 == id) { 10.5 foobar.fchar = barfoo.lchar = 'c'; // if (c = d++) { // if (0!= (c = d++)) { d = (a = b + c) + r; //
a = b + c; d = a + r; 10.6 byte[] buffer; byte buffer[]; 10.7 10.7.1 if ((I) = 42) { // if (a == b && c == d) // if ((a == b) && (c == d)) // 10.7.2 if (booleanexpression) { return true; else { return false; return booleanexpression; if (condition) { return x; return y; return (condition? x : y);
10.7.3 "?" "? : " "?" (x >= 0)? x : -x; 10.7.4 FIXME TODO //FIXME //TODO 11 11.1 Java /* * @(#)Example.java 1.0 2007-4-11 * * Copyright (c) 1998-2007 ChinaCache * All rights reserved. * */ package com.chinacache.example; import com.chinacache.example.mylog; /** * * * @version 1.0 2007-4-11 * @author Jeffrey Hu */
public class Example extends SomeClass { /* */ /** classvar1 JavaDoc */ public static int classvar1; /** * classvar1 JavaDoc * */ private static Object classvar2; /** instancevar1 JavaDoc */ public Object instancevar1; /** instancevar2 JavaDoc */ protected int instancevar2; /** instancevar3 JavaDoc */ private Object[] instancevar3; /** * JavaDoc */ public Example () { // /** * dosomething JavaDoc. */ public void dosomething() { // /** * dosomethingelse JavaDoc. *@param someparam */ public void dosomethingelse(object someparam) { //