1.String的内容一旦声明就无法改变,如下实例:
public class RefDemo{
public static void main(String args[]){
String str = "hello" ;
fun(str) ;
System.out.println(str) ;
}
public static void fun(String temp){
temp = "world" ;
}
};
输出结果为hello。
2.this关键字:this可以调用属性、方法。this在构造方法中,只能放在构造方法的首行。this表示当前对象,说明当前正在操作类中方法的对象。