当前位置: 首页 > news >正文

自己做的网站怎么加入微信支付/aso优化渠道

自己做的网站怎么加入微信支付,aso优化渠道,国外一个做同人动漫的网站,网站建设需要什么手续一:浅拷贝: 只有子类实现Cloneable接口才可以使用Object使用的clone方法。 protected native Object clone() throws CloneNotSupportedException;浅拷贝是将原对象的信息拷贝,拷贝后的对象和原对象指向同一块空间。 class Teacher {private…

一:浅拷贝:
只有子类实现Cloneable接口才可以使用Object使用的clone方法。

protected native Object clone() throws CloneNotSupportedException;

浅拷贝是将原对象的信息拷贝,拷贝后的对象和原对象指向同一块空间。

class Teacher {private String name;private String position;public Teacher(String name, String position) {this.name = name;this.position = position;}@Overridepublic String toString() {return "QianCopy{" +"name='" + name + '\'' +", position='" + position + '\'' +'}';}public void setName(String name) {this.name = name;}
}class Student implements  Cloneable
{private String name;private Integer age;private Teacher teacher;public Student(String name, Integer age, Teacher teacher) {this.name = name;this.age = age;this.teacher = teacher;}@Overrideprotected Student clone() throws CloneNotSupportedException {Student student=null;student=(Student)super.clone();return student;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", age=" + age +", teacher=" + teacher +'}';}
}public class QianCopy
{public static void main(String[] args) throws CloneNotSupportedException {Teacher teacher=new Teacher("ali","manager");Student student=new Student("sophia",10,teacher);System.out.println("这是原student");System.out.println(student);System.out.println("这是cloneStudent");Student cloneStudent=student.clone();System.out.println(cloneStudent);System.out.println("修改techer姓名");teacher.setName("Jack");//修改teacher的名称,student里的teacher姓名会改变System.out.println("这是修改后原student");System.out.println(student);System.out.println("这是修改后cloneStudent");System.out.println(cloneStudent);}
}

在这里插入图片描述上述clone是浅拷贝,因为拷贝后的teacher和原teacher指向同一块空间,原teacher改变,clone后的student里的teacher也改变。

二:深拷贝
深拷贝指:原对象的修改不会影响拷贝后的对象。
利用序列化,因为序列化后:将二进制字节流内容写到一个媒介(文本或字节数组),然后是从这个媒介读取数据,原对象写入这个媒介后拷贝给clone对象,原对象的修改不会影响clone对象,因为clone对象是从这个媒介读取。

import java.io.*;//深拷贝
class Teacher1 implements Serializable {private String name;private String position;public Teacher1(String name, String position) {this.name = name;this.position = position;}@Overridepublic String toString() {return "QianCopy{" +"name='" + name + '\'' +", position='" + position + '\'' +'}';}public void setName(String name) {this.name = name;}
}class Student1 implements  Cloneable,Serializable
{private String name;private Integer age;private Teacher1 teacher;public Student1(String name, Integer age, Teacher1 teacher) {this.name = name;this.age = age;this.teacher = teacher;}public Student1 cloneSer () throws Exception {Student1 student=null;//在内存中创建一个字节数组缓冲区,所有发送到输出流的数据保存在该字节数组中//默认创建一个大小为32的缓冲区ByteArrayOutputStream byOut=new ByteArrayOutputStream();//对象的序列化输出ObjectOutputStream outputStream=new ObjectOutputStream(byOut);//通过字节数组的方式进行传输outputStream.writeObject(this);  //将当前student对象写入字节数组中//在内存中创建一个字节数组缓冲区,从输入流读取的数据保存在该字节数组缓冲区ByteArrayInputStream byIn=new ByteArrayInputStream(byOut.toByteArray()); //接收字节数组作为参数进行创建ObjectInputStream inputStream=new ObjectInputStream(byIn);student=(Student1)inputStream.readObject(); //从字节数组中读取return student;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", age=" + age +", teacher=" + teacher +'}';}
}
public class ShenCopy {public static void main(String[] args) throws Exception {Teacher1 teacher=new Teacher1("ali","manager");Student1 student=new Student1("sophia",10,teacher);System.out.println("这是原student");System.out.println(student);System.out.println("这时cloneStudent");Student1 cloneStudent=student.cloneSer();System.out.println(cloneStudent);System.out.println("将teacher姓名进行修改");teacher.setName("Jack");System.out.println("这是修改后原student");System.out.println(student);System.out.println("这是修改后cloneStudent");System.out.println(cloneStudent);}
}

在这里插入图片描述

http://www.jmfq.cn/news/4975129.html

相关文章:

  • 怡清源在慧聪网网站建设情况/怎样在百度上发帖子
  • 衢州在建高铁站/百度seo排名360
  • 电商眼/阳东网站seo
  • 响应式网站的设计趋势/太原百度搜索排名优化
  • 山东网站优化/快排seo排名软件
  • 郑州的网站建设公司/首页关键词怎么排名靠前
  • 企业网站设置/友情链接互换网站
  • 网站收录代做/如何设置友情链接
  • 赤峰网站开发公司/网店
  • 吴江网站建设/黑帽seo是什么意思
  • 天津市企业网站建设公司/seo做的好的网站
  • 装饰公司响应式网站建设案例/seo实战培训班
  • 陇南市城乡建设局网站/长沙百度搜索排名优化
  • 建设政府门户网站/集合竞价口诀背熟6句
  • 哪个网站开发培训好/福建网络seo关键词优化教程
  • 黄山网站开发jidela/如何网上免费打广告
  • 广州网站建设weeken/seo排名点击
  • 大尺度做爰网站/整合营销传播工具有哪些
  • 网站app怎么做/效果最好的推广软件
  • php对比java做网站/高端网站建设公司
  • 重庆欧勒精细陶瓷有限公司网站策划书/建网站用什么软件
  • 如何做网站推广及优化/国内十大搜索引擎排名
  • 建筑库/淄博搜索引擎优化
  • 做rap的网站/网络黄页推广大全
  • 长沙娱乐网站开发/seo怎么快速提高排名
  • 设计的好网站/谷歌竞价排名推广公司
  • logo智能设计/合肥网络推广优化公司
  • html 公司网站 代码下载/营销型网站策划书
  • 佛山网站建设价格/网络营销成功的原因
  • 凡客诚品鞋子/seo搜索引擎优化人员