java HashSet去重示例
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public class HashSetDemo {
public static void main(String[] args){
List tableList = new ArrayList();
tableList.add("hello");
tableList.add("hell0");
tableList.add("world");
tableList.add("world");
tableList.add(2);
tableList.add(2);
tableList.add(true);
tableList.add(true);
HashSet hs = new HashSet(tableList);
//System.out.println(hs.toString());
//System.out.println(tableList);
Iterator i = hs.iterator();
while(i.hasNext()){
Object temp = i.next();
System.out.println(temp.toString());
}
}
}
输出:
2
true
hell0
hello
world
相关文档:
昨天看到一个题目:java异常机制和垃圾处理机制,发现平时用的时候也没太注意,拿过来就用。学习这东西就得不断总结、积累,不然时间长还谁还记得它长啥样。
java异常基本概念就不用说了,
java异常主要分为三类:
1)编译时异常java.lang.Exception
2)运行时异常 java.lang.RuntimeException
&nb ......
【转】Java中的位运算符
原作者:Rosen Jiang 出处:http://www.blogjava.net/rosen
移位运算符
包括:
“>> 右移”;“<< 左移”;“>>> 无符号右移”
例子:
-5>>3=-1
1111 1111 1111 1111 1111 1111 1111 ......
import java.nio.*;
import java.nio.channel.*;
import java.io.*;
public static void copy(File source, File dest) throws IOException {
FileChannel in = null, ......
http://xxw8393.blog.163.com/blog/static/37256834200910432656672/
Encoding.java
package org.loon.test.encoding;
/** *//**
* <p>
* Title: LoonFramework
* </p>
* <p>
* Description:编码基本类型集合
* </p>
* <p>
* Co ......