摘要:
import java.io.*;
public class FileTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("E:/workspace/Java从入门到精通/mynote.txt");
if(file.exists())
{
file.delete();
System.out.println("文件已经删除。");
}
else
{
try{
file.createNewFile();
System.out.println("文件已经创建。");
}catch(Exception e)
{
e.printStackTrace();
}
}
}
} 阅读全文
posted @ 2010-08-31 20:49
叮当小马
阅读(256)
评论(0)
推荐(0)
摘要:
import java.util.*; //导入类
public class MapTest {
/**
* @param args
*/
public static void main(String[] args){
Map map = new HashMap();
Emp emp = new Emp("001","张三");
Emp emp2 = new Emp("005","张四"); //创建emp对象
Emp emp3 = new Emp("004","王一");
map.put(emp.getE_id(), emp.getE_name());
map.put(emp2.getE_id(), emp2.getE_name());
map.put(emp3.getE_id(), emp3.getE_name());
Set set = map.keySet();
Iterator it = set.iterator();
System.out.println( 阅读全文
posted @ 2010-08-31 20:42
叮当小马
阅读(311)
评论(0)
推荐(0)
摘要:
import java.util.*; //导入类
public class ListGather {
/**
* @param args
*/
public static void main(String[] args) {
List list = new ArrayList(); //集合类
list.add("a");
list.add("b");
list.add("c");
int i = (int)(Math.random()*(list.size()-1)); //0-2
System.out.println("随机获得数组中的元素:"+list.get(i));
for(int j =0;jlist.size();j++) //循环遍历集合
{
System.out.println(list.get(j));
}
}
} 阅读全文
posted @ 2010-08-31 20:39
叮当小马
阅读(242)
评论(0)
推荐(0)