[JAVA] 深克隆 另外实现方法【序列化】
private static List cloneObject(
Object obj) throws Exception {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(obj);
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut
.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
return in.readObject();
}
相关文档:
一、什么是JSON
JSON 即 JavaScript Object Natation(Java对象表示法),它是一种轻量级的数据交换格式,非常适合于服务器与 JavaScript 的交互。
简而言之,JSON就是JavaScript交换数据的一种格式。例子如下:
{"username":"coolcooldool","password":"1230","usertype":"superadmin"}
{"list":[{"password": ......
参考代码:
class SuperClass {
private int n;
SuperClass() {
System.out.println("SuperClass()");
}
SuperClass(int n) {
System.out.println("SuperClass(" + n + ")");
this.n = n;
}
}
class SubClass extends SuperClass {
private int n ......
好久没用java,突一写起来,发现机器上没有设置环境变量,把设置方法总结一下
1. 修改/etc/profile文件
如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性问题。
·用文本编辑器打开/etc/profile
·在pr ......