标签:android style blog http ar io color 使用 sp
<A href="http://www.goodprogrammer.org/" target="blank">android培训</a>------我的java笔记,期待与您交流!
1.Set接口
Set集合不允许重复元素,是因为Set判断两个对象相同不是使用==运算符,而是根据equals方法。即两个对象用equals方法比较返回true,Set就不能接受两个对象。
public class SetDemo
{
	public static void main(String[] args) 
	{
		Set<String> set = new HashSet<String>();
		
		//添加一个字符串对象
		set.add(new String("abcde"));
		
		//再次添加一个字符串对象,
		set.add(new String("abcde"));
		//下面输出看到集合只有一个元素
		System.out.println(set);	
	}
}
2.HashSet
1)HashSet不是同步的,多个线程访问是需要通过代码保证同步
2)集合元素值可以使null
   主要方法:主要方法
    add(Object)
     addAll(Collection)
     remove(object)
     removeAll(Collection)
     size()
     iterator()
     toArray()
     clear()
     isEmpty()
     contain(object)
     containAll(Collection)
标签:android style blog http ar io color 使用 sp
原文地址:http://www.cnblogs.com/bye-2012lx/p/4172836.html