public class myPolSchema {
private String GrpContNo;
private String GrpPolNo;
public String getGrpContNo() {
return GrpContNo;
}
public void setGrpContNo(String aGrpContNo) {
GrpContNo = aGrpContNo;
}
public String getGrpPolNo() {
return GrpPolNo;
}
public void setGrpPolNo(String aGrpPolNo) {
GrpPolNo = aGrpPolNo;
}
public myPolSchema(String GrpContNo,String GrpPolNo){
this.GrpContNo=GrpContNo;
this.GrpPolNo=GrpPolNo;
}
public boolean equals(Object otherObject) {
if (this == otherObject)
return true;
if (otherObject == null)
return false;
if (getClass() != otherObject.getClass())
return false;
if(!(otherObject instanceof myPolSchema)){
return false;
}else{
myPolSchema other = (myPolSchema) otherObject;
return GrpContNo.equals(other.getGrpContNo())
&& GrpPolNo.equals(other.getGrpPolNo());
}
}
}
---------------------------
import java.util.* ;
public class MultiThreading{
// implements Runnable
Map m=Collections.synchronizedMap(new HashMap());
//HashMap m=new HashMap();
Hashtable t=new Hashtable();
public myPolSchema polschema;
public void run(int i)
{
polschema=new myPolSchema(i+"",i+"");
m.put(polschema, "UPDATE");
System.out.println("put end at " + new Date());
}
public static void main(String[] args) throws Exception {
MultiThreading t=new MultiThreading();
for(int i=0;i<=25000;i++){
try{
t.run(i);
//Thread.sleep(100);
}
catch(Exception ex){
//在我本地測(cè)試時(shí)當(dāng)運(yùn)行大概1500左右次的時(shí)間就會(huì)拋出NullPointerException
System.out.println("i is: " + i);
throw ex;
}
}
}
}
構(gòu)造方法啊大哥 不賦值怎么能比較呢
回復(fù) 更多評(píng)論