同样的程序,怎么会有不同的结果?
package shiyan2;
import java.util.*;
import java.io.*;
public class shiyan
{
public static void main(String args[])
{
shiyan1 as=new shiyan1();
Vector aa=new Vector();
as.setcc(aa);
System.out.println(as.getcc().size());
}
}
package shiyan2;
import java.util.*;
import java.io.*;
public class shiyan1
{
private Vector cc=new Vector();
public void setcc(Vector dd)
{
cc.addElement(dd);
}
public Vector getcc()
{
return cc;
}
}
输出结果为: 1
package shiyans;
import java.util.*;
import java.io.*;
public class shiyan
{
public static void main(String []args)
{
shiyan1 bb=new shiyan1();
Vector sa=new Vector();
bb.setcc(sa);
System.out.println(bb.getcc().size());
}
}
package shiyans;
import java.util.*;
import java.io.*;
public class shiyan1
{
private Vector cc=new Vector();
public void setcc(Vector dd)
{
cc.addElement(dd);
}
public Vector getcc()
{
return cc;
}
}
输出结果为: 0
为什么呀,我用的是jcreator
------解决方案--------------------我这边运行时一样的么,不过我用的是eclipse
------解决方案--------------------up
------解决方案--------------------命名规范真好啊,眼晕了。单体测试还真不少,哈哈!!