Clone

时间:2025-04-06 20:07:25

Clone:

构建一个对象的时候,是不是一定要调用构造函数!

package com.edu.test;

public class Zhenzhen implements Cloneable{

public Zhenzhen(){

System.out.println("new Instance");

}

public String name;

public String female;

public static void main(String[] args) throws Exception {

Zhenzhen z = new Zhenzhen();

z.name="李珍";

z.female="女妖";

Zhenzhen nz = (Zhenzhen)z.clone();

System.out.println(nz.name+" "+nz.female);

System.out.println(z);

System.out.println(nz);

}

}

Example:

while(rs.next)(){

Userinfo info = new Userinfo();

info.setUname(rs.getString(2));

info.setUpass(rs.getString(3));

}

Clone

Clone

爱卡(深圳)管理有限公司

分享每一刻精彩

微信:iCafeYOJOY

微博:http://weibo.com/iCafeYOJOY

官网:www.icafe.im