Java基础恶补——Development

[SCJP Sun Certified Programmer for Java 6 Study Guide (Exam 310-065)]  chapter10

一. 使用 javac 和 java
1. 使用 javac 命令时,可以用 -d 改变class文件的目的地。

2. The -d option can build package-dependent destination classes on-the-fly if the root package directory already exists.

3. 使用 java 命令时,可以用 -D 来使用系统变量。

4. System properties consist of name=value pairs that must be appended directly behind the -D, for example, java -Dmyproperty=myvalue.

5. 命令行参数总是作为String来看待的。

6. The java command-line argument 1 is put into array element 0, argument 2 is put into element 1, and so on.

 

二. 用 javac 和 java 搜索
1. Both java and javac use the same algorithms to search for classes.

2. Searching begins in the locations that contain the classes that come standard with J2SE.

3. Users can define secondary search locations using classpaths.

4. Default classpaths can be defined by using OS environment variables.

5. A classpath can be declared at the command line, and it overrides the default classpath.

6. A single classpath can define many different search locations.

7. In Unix classpaths, forward slashes (/) are used to separate the directories that make up a path. In Windows, backslashes (\) are used.

8. In Unix, colons (:) are used to separate the paths within a classpath. In Windows, semicolons (;) are used.

9. In a classpath, to specify the current directory as a search location, use a dot (.)

10. In a classpath, once a class is found, searching stops, so the order of locations to search is important.

 

三. 打包和搜索
1. When a class is put into a package, its fully qualified name must be used.

2. An import statement provides an alias to a class's fully qualified name.

3. In order for a class to be located, its fully qualified name must have a tight relationship with the directory structure in which it resides.

4. A classpath can contain both relative and absolute paths.

5. An absolute path starts with a / or a \.

6. Only the final directory in a given path will be searched.

 

四. JAR 文件
1. An entire directory tree structure can be archived in a single JAR file.

2. JAR files can be searched by java and javac.

3. When you include a JAR file in a classpath, you must include not only the directory in which the JAR file is located, but the name of the JAR file too.

4. For testing purposes, you can put JAR files into .../jre/lib/ext, which is somewhere inside the Java directory tree on your machine.

 

五. 静态导入
1. You must start a static import statement like this: import static.

2. You can use static imports to create shortcuts for static members (static variables, constants, and methods) of any class.

 

你可能感兴趣的:(java基础)