class Address{
String Detail;
public Address(String detail){
this.Detail = detail;
}
} class User implements Cloneable{
int age;
Address address; public User(int age){
this.age = age;
this.address = new Address("houyang");
} public User clone() throws CloneNotSupportedException{
return (User) super.clone();
}
} public class CloneTest {
public static void main(String[] args) throws CloneNotSupportedException {
var c1 = new User();
var c2 = c1.clone(); System.out.println(c1 == c2);
System.out.println(c1.address == c2.address); }
}

output:

false
true

  

learning java Cloneable的更多相关文章

  1. Learning Java language Fundamentals

    Chapter 2 Learning Java language fundamentals exercises: 1.What  is Unicode? Unicode is a computing ...

  2. Learning Java 8 Syntax (Java in a Nutshell 6th)

    Java is using Unicode set Java is case sensitive Comments, C/C++ style abstract, const, final, int, ...

  3. blogs for learning java

    曹海成的专栏 http://blog.csdn.net/caohaicheng/article/details/38071097 http://blog.csdn.net/a5489888/artic ...

  4. Learning Java IO indexes

    I/O Streams, it simplifies I/O operations, write a whole object out to stream & read back. File ...

  5. Learning Java characteristics (Java in a Nutshell 6th)

    Java characteristics: Java .class files are machine-independent, including the endianness. Java .cla ...

  6. [Java in NetBeans] Lesson 00. Getting Set-up for Learning Java

    这个课程的参考视频在youtube. 主要学到的知识点有: set up needs Java SE JDK, NetBeans IDE class name should be the same l ...

  7. learning java 使用WatchService监控文件变化

    import java.io.IOException; import java.nio.file.*; public class WatchServiceTest { public static vo ...

  8. learning java FileVisitor 遍丽文件及路径

    import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttribut ...

  9. learning java Paths Path

    import java.nio.file.Path; import java.nio.file.Paths; public class PathTest { public static void ma ...

随机推荐

  1. 【C语言】了解原码、反码、补码

    原码.反码.补码 在学习C语言的过程中,有遇到补码这个问题,当时感觉懂了,有貌似不是很懂:然后查了一些文档,整理了一番,以后忘记了可以再翻开这篇文档,查漏补缺吧! 原码 原码是指一个二进制数左边加上符 ...

  2. Dubbo快速入门 三

    3.dubbo环境搭建 3.1).[windows]-安装zookeeper 1.下载zookeeper 网址 https://archive.apache.org/dist/zookeeper/zo ...

  3. 集成maven和Spring boot的profile

    如果在配置中勾选了多套配置,则以pom.xml文件中 profiles中  配置 最后一个配置为准. maven中配置profile节点: <project> .... <profi ...

  4. Atcoder Grand Contest 036 D - Negative Cycle

    Atcoder Grand Contest 036 D - Negative Cycle 解题思路 在某些情况下,给一张图加或删一些边要使图合法的题目要考虑到最短路的差分约束系统.这一题看似和最短路没 ...

  5. RequestBody只能读取一次的问题

    一.为什么只能读一次 原因很简单:因为是流.想想看,java中的流也是只能读一次,因为读完之后,position就到末尾了. 二.解决办法 思路:第一次读的时候,把流数据暂存起来.后面需要的时候,直接 ...

  6. DevExtreme学习笔记(一) DataGrid中注意事项

    1.阻止cell编辑 config.onEditorPreparing = function (e) { if (e.dataField === 'xx' && e.row.data. ...

  7. 【洛谷 SP8093】 JZPGYZ - Sevenk Love Oimaster(后缀自动机)

    题目链接 广义sam.. #include <cstdio> #include <cstring> #include <algorithm> using names ...

  8. Oracle 用户模式

    在 Oracle 数据库中,为了便于管理用户所创建的数据库对象(数据表.索引.视图等),引入了模式的概念,这样某个用户所创建的数据库对象就都属于该用户模式. 一.模式与模式对象 模式是一个数据库对象的 ...

  9. Android应用通过JDBC直连阿里云MySQL数据库

    1.设置白名单,获取外网连接地址 外部设备要访问阿里云MySQL数据库,则需要设置白名单,具体操作链接: https://help.aliyun.com/document_detail/43185.h ...

  10. Flask-SQLAlchemy操作指南

    Flask-SQLAlchemy官方文档 from flask_sqlalchemy import SQLAlchemy app = Flask(__name__)app.config['SQLALC ...