- class Demo665
- {
- public static void main(String[] args)
- {
- final Person p=new Person("lisi",22);
- p.name="zhangsan";
- p.age=223;
- //Person p1=new Person("wangwu",90);
- //p=p1;
- System.out.println(p.name+p.age);
- }
- }
- class Person
- {
- String name;
- int age;
- Person(String name,int age)
- {
- this.name=name;
- this.age=age;
- }
- }
复制代码 看我代码,final修饰的对象的指向不能变,但是指向的对象的值是可以变的 |