Skip to content

Commit f7b2554

Browse files
committed
更新
1 parent 45fe911 commit f7b2554

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Part4/StaticTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ public double getSalary() {
4444
public int getID() {
4545
return id;
4646
}
47-
47+
48+
/* 在这里我们可以看到,
49+
* 实际上被定义成static变量的nextId也是可以被修改的,
50+
* 因为静态变量也是变量;
51+
* 如果不想被修改的话,
52+
* 还需要加上final进行修饰
53+
*/
4854
public void setId() {
4955
id = nextId;
5056
nextId++;
5157
}
5258

59+
/* 只能通过静态方法访问自身的静态域 */
5360
public static int getNextId() {
5461
return nextId;
5562
}

README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
简介:
2-
《Core Java》学习手册
2+
《Core Java》学习笔记。
3+
我把自己的笔记都以注释的形式写在代码里面了,这样方便理解。
34

45
参考:
56
《Core Java Volumn I》

0 commit comments

Comments
 (0)