zoukankan      html  css  js  c++  java
  • 反射认识_06_ArrayList_HashSet区别

    包01:

    package ReflectionCollection;
    
    public class ReflectionConstructorPoint {
    	private int x;
    	public int y;
    	
    	public ReflectionConstructorPoint(int x, int y) {
    		super();
    		this.x = x;
    		this.y = y;
    	}
    }
    

      

    包02:

    package ReflectionCollection;
    
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashSet;
    
    public class ReflectionConstructor {
    	public static void main(String[] args) throws Exception {
    		ReflectionConstructorPoint rcp1=new ReflectionConstructorPoint(1, 1);
    		ReflectionConstructorPoint rcp2=new ReflectionConstructorPoint(2, 2);
    		ReflectionConstructorPoint rcp3=new ReflectionConstructorPoint(3, 3);
    
    		/*验证ArrayList,重复添加后大小,有序集合*/
    		Collection col1=new ArrayList();
    		col1.add(rcp1);
    		col1.add(rcp1);//第二次添加
    		col1.add(rcp2);
    		col1.add(rcp3);
    		System.out.println(col1.size());//结果为4
    
    		/*验证HashSet,重复添加后大小,无序集合*/
    		Collection col2=new HashSet();
    		col2.add(rcp1);
    		col2.add(rcp1);//第二次添加
    		col2.add(rcp2);
    		col2.add(rcp3);
    		System.out.println(col2.size());//结果为3
    	}
    }
    

      

  • 相关阅读:
    UnityShader
    Unity
    Tools
    linux下解压命令
    进程 同步、互斥
    I/O模型
    jclass jobject
    javah javap
    IDA 结构体
    Windows CSRSS API List (NT/2000/XP/2003/Vista/2008/7/2012/8)
  • 原文地址:https://www.cnblogs.com/zjsy/p/4154031.html
Copyright © 2011-2022 走看看