clonedemo.java

来自「一个用JAVA写的序列化的例子 大家看看 不大 但能说明问题 」· Java 代码 · 共 24 行

JAVA
24
字号
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 + =
减小字号Ctrl + -
显示快捷键?