📄 clonedemo.java
字号:
import java.lang.Cloneable;
//浅复制模式
class student implements Cloneable{
String name="wangwu";
int age=30;
teacher aa=new teacher();
public Object clone() throws CloneNotSupportedException{
return super.clone();
}
}
class teacher{
String name="lfieing";
}
class test{
public static void main (String[] args) throws Exception{
student dd=new student();
student ee=(student)dd.clone();
System.out.println (dd==ee);
System.out.println (dd.aa==ee.aa);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -