learning java Cloneable
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的更多相关文章
- Learning Java language Fundamentals
Chapter 2 Learning Java language fundamentals exercises: 1.What is Unicode? Unicode is a computing ...
- 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, ...
- blogs for learning java
曹海成的专栏 http://blog.csdn.net/caohaicheng/article/details/38071097 http://blog.csdn.net/a5489888/artic ...
- Learning Java IO indexes
I/O Streams, it simplifies I/O operations, write a whole object out to stream & read back. File ...
- Learning Java characteristics (Java in a Nutshell 6th)
Java characteristics: Java .class files are machine-independent, including the endianness. Java .cla ...
- [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 ...
- learning java 使用WatchService监控文件变化
import java.io.IOException; import java.nio.file.*; public class WatchServiceTest { public static vo ...
- learning java FileVisitor 遍丽文件及路径
import java.io.IOException; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttribut ...
- learning java Paths Path
import java.nio.file.Path; import java.nio.file.Paths; public class PathTest { public static void ma ...
随机推荐
- 「CTS2019」珍珠
「CTS2019」珍珠 解题思路 看了好多博客才会,问题即要求有多少种方案满足数量为奇数的变量数 \(\leq n-2m\).考虑容斥,令 \(F(k)\) 为恰好有 \(n\) 个变量数量为奇数的方 ...
- Centos Consul集群及Acl配置
一,准备工作 准备四台centos服务器,三台用于consul server 高可用集群,一台用于consul client作服务注册及健康检查.架构如下图所示 二,在四台服务器上安装consul 1 ...
- select ng-change 方法中 拿不到 ng-modal 定义的变量值
在使用angularjs框架的项目中,select 的数据源有两种绑定方式,在option中使用ng-repeat循环绑定,或者在select中使用ng-option 绑定. 无论哪种绑定方式,均要使 ...
- fiddler数据过滤功能
设置会话过滤的菜单如下图: 1.勾选Use Filters选项表示使用过滤设置,不勾选则不使用 2.Actions:有四个选项 Run Filterset now:立即运行过滤设置: Load Fil ...
- fastDFS的入门程序
导入jar包 <dependency> <groupId>cn.bestwu</groupId> <artifactId>fastdfs-client- ...
- native function 'Window_sendPlatformMessage' (4 arguments) cannot be found
https://github.com/pauldemarco/flutter_blue/issues/140 https://github.com/flutter/flutter/issues/168 ...
- input中blur失去焦点事件与点击事件冲突时如何解决
方法一 使用setTimeout $(function(){ $(".cy-name-input input").on({ focus:function() { $(". ...
- Android Jetpack组件
带你领略Android Jetpack组件的魅力 Android新框架jetpack的内容讲解:Room.WorkManager.LifeCycles.LiveData.ViewModel.DataB ...
- 在Xcode4 中将iPhone使用的xib转换成iPad使用的xib
来源:http://blog.3snews.net/space.php?uid=6188&do=blog&id=64200 http://www.giser.net/?p=982 1 ...
- 如何方便引用自己的python包
有时候想要把一些功能封装成函数然后包装到模块里面最后形成一个包,然后在notebook里面去引用它去处理自己的数据和分析一些有用的部分,比如自己在 之前用到的一个datascience模板就是这样组织 ...