day11--final关键字用于修饰成员变量

This commit is contained in:
xx
2026-10-09 14:15:35 +08:00
parent 688627e75a
commit bf1179fe97
+19
View File
@@ -0,0 +1,19 @@
package com.inmind.final01;
/*
final关键字用于修饰成员变量
成员变量:类中方法外
*/
public class Demo04 {
//成员变量
final int i = 1;
final int j;//可以通过构造方法,赋值
public Demo04(int j){
this.j = j;
}
public static void main(String[] args) {
}
}