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. Python定义点击右上角关闭按钮事件

    Python定义点击右上角关闭按钮事件(Python defines the event of clicking the close button in the upper right corner) ...

  2. Android 低功耗蓝牙BLE 开发注意事项

    基本概念和问题 1.蓝牙设计范式? 当手机通过扫描低功耗蓝牙设备并连接上后,手机与蓝牙设备构成了客户端-服务端架构.手机通过连接蓝牙设备,可以读取蓝牙设备上的信息.手机就是客户端,蓝牙设备是服务端. ...

  3. Android目前流行三方数据库ORM分析及对比

    Android 平台上的数据库框架非常多,但是有一个共同特点就是基于对象关系映射(ORM)模型的.实现的目标也都是不需要写SQL语句,通过对对象的操作保存和操作数据.要是从语法的简洁性来说都有自己的特 ...

  4. MySQL FEDERATED引擎使用示例, 类似Oracle DBLINK(转)

    1 引擎说明 本地MySQL数据库要访问远程MySQL数据库的表中的数据, 必须通过FEDERATED存储引擎来实现. 有点类似Oracle中的 数据库链接(DBLINK). 要允许这个存储引擎, 当 ...

  5. MySQL Index--CREATE INDEX在各版本的优化

    FIC(Fast index creation)特性在MySQL 5.5版本中引入FIC(Fast index creation)特性,创建索引时无需再拷贝整表数据,以提升索引的创建速度. FCI 操 ...

  6. linux maven 安装与配置

    Apache Maven,是一个软件(特别是Java软件)项目管理及自动构建工具,由Apache软件基金会所提供.基于项目对象模型(缩写:POM)概念,Maven利用一个中央信息片断能管理一个项目的构 ...

  7. Jackson动态处理返回字段

    有时候业务需要动态返回字段,比如, 场景一:返回 name , birthday, createDate 场景二:返回name, birthday, age 现做个备忘录,以便参考. 下面是引入的PO ...

  8. Centos7安装autoconf

    一.原因 安装此插件的原因:在初始化MySQL数据库时出现提示FATAL ERROR: please install the following Perl modules before executi ...

  9. Bash基础——工作管理(Job control)

    注:1.这里说的Bash不单纯的指Bash,泛指shell 2.这里的后台指的是Bash下面避免任务(Jobs)被Ctrl+C中断的一种场景,与我们说的deamon那种后台工作的进程不是一个概念,注意 ...

  10. [S32K]FreeRTOS使用

    参考官方: Tutorial: FreeRTOS 10.0.1 with NXP S32 Design Studio 2018.R1 (官方component是V8.2.1,此文档介绍如何升级到V10 ...