java 传值方式集合与非集合的区别

来源:互联网 发布:js更新json值 编辑:程序博客网 时间:2024/06/07 17:05
public class test {
static CopyOnWriteArrayList<Integer>arrayList;
static AtomicInteger atomicInteger;
static ArrayList<String>a;
static ArrayList<String>b=null;
static String xString="1";
static String p;
//static ArrayList<Integer>arrayList;
public static void main(String[] args)  {
// TODO Auto-generated method stub
/**
* arrayList=new CopyOnWriteArrayList<>();
for(int i=0; i<10; i++){
arrayList.add(i);
}
for(Integer integer:arrayList){
if (integer==3) {
arrayList.remove(integer);
System.out.println(integer);
}

}
int a=1;
int b=1;
final int c=a/b;
System.out.println(c);
a=2;
System.out.println(c);
*/
p=xString;
System.out.println(p);
xString="adasd";
System.out.println(p);
a=new ArrayList();
b=a;
System.out.println(b.size());
a.add("");
a.add("");
System.out.println(b.size());
atomicInteger=new AtomicInteger();
System.out.println(atomicInteger);
if (atomicInteger.incrementAndGet()==1) {
System.out.println(atomicInteger);
}
//System.out.println(atomicInteger);
//atomicInteger.incrementAndGet();
//System.out.println(atomicInteger);
//System.out.println(atomicInteger.intValue());


}
static void paochuyichang() throws MyException{
throw new test().new MyException("this");
}
public class MyException extends Exception
{
  public MyException()
  {


  }
  public MyException(String s)
  {
        super(s);
  }


}


}

集合,map,数组传的是内存地址,非集合传的是值