Skip to content

Commit 54f466d

Browse files
author
Justin Lin
committed
UPDATE README
1 parent 8047d36 commit 54f466d

File tree

1,002 files changed

+116129
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,002 files changed

+116129
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ JavaSE8Tutorial
22
===============
33

44
Java SE 8 技術手冊
5+
6+
- [書中範例(含錄影檔)下載](http://dlcenter.gotop.com.tw/SampleFiles/ACL042200/download/javase8_techbook_resources.zip)
7+
- [課後解答下載](http://openhome.cc/upload/javase8-exercises.zip)
8+
- [堪誤](correct_errors.md)
9+

labs/CH04/Array/nbproject/project.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.java.j2seproject</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
6+
<name>Array</name>
7+
<source-roots>
8+
<root id="src.dir"/>
9+
</source-roots>
10+
<test-roots>
11+
<root id="test.src.dir"/>
12+
</test-roots>
13+
</data>
14+
</configuration>
15+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cc.openhome;
2+
3+
import java.util.Arrays;
4+
5+
public class CopyArray {
6+
public static void main(String[] args) {
7+
int[] scores1 = {88, 81, 74, 68, 78, 76, 77, 85, 95, 93};
8+
int[] scores2 = Arrays.copyOf(scores1, scores1.length);
9+
for(int score : scores2) {
10+
System.out.printf("%3d", score);
11+
}
12+
System.out.println();
13+
scores2[0] = 99;
14+
// 不影響score1參考的陣列物件
15+
for(int score : scores1) {
16+
System.out.printf("%3d", score);
17+
}
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cc.openhome;
2+
3+
class Clothes2 {
4+
String color;
5+
char size;
6+
Clothes2(String color, char size) {
7+
this.color = color;
8+
this.size = size;
9+
}
10+
}
11+
12+
public class DeepCopy {
13+
public static void main(String[] args) {
14+
Clothes2[] c1 = {new Clothes2("red", 'L'), new Clothes2("blue", 'M')};
15+
Clothes2[] c2 = new Clothes2[c1.length];
16+
for(int i = 0; i < c1.length; i++) {
17+
/*
18+
* 補上程式碼
19+
*/
20+
}
21+
c1[0].color = "yellow";
22+
System.out.println(c2[0].color);
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cc.openhome;
2+
3+
public class IntegerArray {
4+
public static void main(String[] args) {
5+
Integer[] scores = new Integer[3];
6+
for(Integer score : scores) {
7+
System.out.println(score);
8+
}
9+
scores[0] = new Integer(99);
10+
scores[1] = new Integer(87);
11+
scores[2] = new Integer(66);
12+
for(Integer score : scores) {
13+
System.out.println(score);
14+
}
15+
}
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package cc.openhome;
2+
3+
public class IrregularArray {
4+
public static void main(String[] args) {
5+
/*
6+
* 補上程式碼
7+
*/
8+
}
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package cc.openhome;
2+
3+
public class Scores {
4+
public static void main(String[] args) {
5+
int[] scores = {88, 81, 74, 68, 78, 76, 77, 85, 95, 93};
6+
for(int i = 0; i < scores.length; i++) {
7+
System.out.printf("學生分數:%d %n", scores[i]);
8+
}
9+
}
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package cc.openhome;
2+
3+
import java.util.Arrays;
4+
5+
public class Scores2 {
6+
public static void main(String[] args) {
7+
int[] scores = new int[10];
8+
for(int score : scores) {
9+
System.out.printf("%2d", score);
10+
}
11+
System.out.println();
12+
Arrays.fill(scores, 60);
13+
for(int score : scores) {
14+
System.out.printf("%3d", score);
15+
}
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cc.openhome;
2+
3+
class Clothes {
4+
String color;
5+
char size;
6+
Clothes(String color, char size) {
7+
this.color = color;
8+
this.size = size;
9+
}
10+
}
11+
12+
public class ShallowCopy {
13+
public static void main(String[] args) {
14+
Clothes[] c1 = {new Clothes("red", 'L'), new Clothes("blue", 'M')};
15+
Clothes[] c2 = new Clothes[c1.length];
16+
for(int i = 0; i < c1.length; i++) {
17+
c2[i] = c1[i];
18+
}
19+
c1[0].color = "yellow";
20+
System.out.println(c2[0].color);
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package cc.openhome;
2+
3+
public class XY {
4+
5+
public static void main(String[] args) {
6+
int[][] cords = {
7+
{1, 2, 3},
8+
{4, 5, 6}
9+
};
10+
/*
11+
* 補上程式碼
12+
* /
13+
14+
}
15+
}

labs/CH04/ClassObject/build.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See commented blocks below for -->
3+
<!-- some examples of how to customize the build. -->
4+
<!-- (If you delete it and reopen the project it will be recreated.) -->
5+
<!-- By default, only the Clean and Build commands use this build script. -->
6+
<!-- Commands such as Run, Debug, and Test only use this build script if -->
7+
<!-- the Compile on Save feature is turned off for the project. -->
8+
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9+
<!-- in the project's Project Properties dialog box.-->
10+
<project name="ClassObject" default="default" basedir=".">
11+
<description>Builds, tests, and runs the project ClassObject.</description>
12+
<import file="nbproject/build-impl.xml"/>
13+
<!--
14+
15+
There exist several targets which are by default empty and which can be
16+
used for execution of your tasks. These targets are usually executed
17+
before and after some main targets. They are:
18+
19+
-pre-init: called before initialization of project properties
20+
-post-init: called after initialization of project properties
21+
-pre-compile: called before javac compilation
22+
-post-compile: called after javac compilation
23+
-pre-compile-single: called before javac compilation of single file
24+
-post-compile-single: called after javac compilation of single file
25+
-pre-compile-test: called before javac compilation of JUnit tests
26+
-post-compile-test: called after javac compilation of JUnit tests
27+
-pre-compile-test-single: called before javac compilation of single JUnit test
28+
-post-compile-test-single: called after javac compilation of single JUunit test
29+
-pre-jar: called before JAR building
30+
-post-jar: called after JAR building
31+
-post-clean: called after cleaning build products
32+
33+
(Targets beginning with '-' are not intended to be called on their own.)
34+
35+
Example of inserting an obfuscator after compilation could look like this:
36+
37+
<target name="-post-compile">
38+
<obfuscate>
39+
<fileset dir="${build.classes.dir}"/>
40+
</obfuscate>
41+
</target>
42+
43+
For list of available properties check the imported
44+
nbproject/build-impl.xml file.
45+
46+
47+
Another way to customize the build is by overriding existing main targets.
48+
The targets of interest are:
49+
50+
-init-macrodef-javac: defines macro for javac compilation
51+
-init-macrodef-junit: defines macro for junit execution
52+
-init-macrodef-debug: defines macro for class debugging
53+
-init-macrodef-java: defines macro for class execution
54+
-do-jar: JAR building
55+
run: execution of project
56+
-javadoc-build: Javadoc generation
57+
test-report: JUnit report generation
58+
59+
An example of overriding the target for project execution could look like this:
60+
61+
<target name="run" depends="ClassObject-impl.jar">
62+
<exec dir="bin" executable="launcher.exe">
63+
<arg file="${dist.jar}"/>
64+
</exec>
65+
</target>
66+
67+
Notice that the overridden target depends on the jar target and not only on
68+
the compile target as the regular run target does. Again, for a list of available
69+
properties which you can use, check the target you are overriding in the
70+
nbproject/build-impl.xml file.
71+
72+
-->
73+
</project>

labs/CH04/ClassObject/manifest.mf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
X-COMMENT: Main-Class will be added automatically by build
3+

0 commit comments

Comments
 (0)