9月6日 自学问题
1.引用类型所存储的是地址值,但地址值中包含类型。如果想在引用变量中赋值,要有相同的类型
如: Person p = new Person();
User user = p; X 错误
2.String 是引用类型,但是在存储过程中使用char [] 数组存的,字符串常量池在方法区不能更改(char 【】 数组类型想要更改只能new 一个新的)
因此在方法中
String str = "hello";
Demo test = new Demo();
test.a(str);
sout(str) // str仍为hello
public void a(String){
s= "hi.." // 创建了一个新的char数组接收
}
3.四种权限符号
peivate 只能在类中调用
缺省 可以在同一类中和同一个包内调用
protected 可以在类中,包中和不同包的子类(继承性)中调用
public 同一个工程(程序)都能调用

浙公网安备 33010602011771号