- 讲师:刘萍萍 / 谢楠
- 课时:160h
- 价格 4580 元
特色双名师解密新课程高频考点,送国家电网教材讲义,助力一次通关
配套通关班送国网在线题库一套
百度广告
import java.awt.Point;import java.io.IOException;import com.sun.corba.se.impl.io.OptionalDataException;/** * 克隆测试 |
import java.awt.Point;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import com.sun.corba.se.impl.io.OptionalDataException;/** * 正方形 * * @author 88250 * @version 1.0.0, 2007-8-26 */public class Square implements Cloneable, Serializable{ private Point location = new Point(0, 0); private float sideLength = 1F; @Override public Object clone() { Square tmp = null; try { tmp = (Square) super.clone(); } catch (CloneNotSupportedException cnse) { cnse.printStackTrace(); } finally { return tmp; } } /** * 深克隆方法 * @return */ public Object deepClone() throws IOException, OptionalDataException, ClassNotFoundException { // 首先将对象写到流里 ByteArrayOutputStream bo = new ByteArrayOutputStream(); ObjectOutputStream oo = new ObjectOutputStream(bo); oo.writeObject(this); // 然后将对象从流里读出来 ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); ObjectInputStream oi = new ObjectInputStream(bi); return (oi.readObject()); } /** * @return the location */ public Point getLocation() { return location; } /** * @param location the location to set */ public void setLocation(Point location) { this.location = location; } /** * @return the sideLength */ public float getSideLength() { return sideLength; } /** * @param sideLength the sideLength to set */ public void setSideLength(float sideLength) { this.sideLength = sideLength; }} |
责编:罗莉
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
课程专业名称 |
讲师 |
课时 |
查看课程 |
---|
点击加载更多评论>>