摘要: import java.io.*; public class TestFileReader { public static void main(String[] args) { FileReader fr = null; int c = 0; try { fr = new FileReader("C:/java/Test.java"); while((c = fr.read()) != -1) { System.out.print((char)c); } fr.close(); } catch (FileNotFoundExcepti... 阅读全文
posted @ 2012-05-01 22:18 spring3 阅读(155) 评论(0) 推荐(0) 编辑
摘要: import java.io.*; public class Test { public static void main(String[] args) { int b = 0; FileInputStream in = null; try { in = new FileInputStream("C:/java/Test.java"); } catch (FileNotFoundException e) { System.out.println("找不到指定文件"); System.exit(-1); } try { ... 阅读全文
posted @ 2012-05-01 21:37 spring3 阅读(221) 评论(0) 推荐(0) 编辑
摘要: //TestArsgWords.java import java.util.*; public class TestArgsWords { public static void main(String[] args) { Map<String, Integer> m = new HashMap<String, Integer>(); for(int i = 0; i < args.length; i++) { if(!m.containsKey(args[i])) { m.put(args[i], 1); } else { int fr... 阅读全文
posted @ 2012-05-01 15:06 spring3 阅读(328) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; public class TestArgsWords { public static void main(String[] args) { Map m = new HashMap(); for(int i = 0; i < args.length; i++) { int freq = ((Integer) m.get(args[i]) == null ? 0 : (Integer) m.get(args[i])); m.put(args[i], (freq == 0 ? 1 : freq + 1)); } ... 阅读全文
posted @ 2012-05-01 14:41 spring3 阅读(245) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; public class Test { public static void main(String[] args) { Map m1 = new HashMap(); Map m2 = new HashMap(); m1.put("one", 1); //m1.put("one",new Integer(1)); m1.put("two", 2); //m1.put("two",new Integer(2)); m1.put("three", 3); / 阅读全文
posted @ 2012-05-01 14:21 spring3 阅读(208) 评论(0) 推荐(0) 编辑
摘要: import java.lang.Comparable; import java.util.List; import java.util.LinkedList; import java.util.Collections; public class TestCompareTo { public static void main(String[] args) { List l1 = new LinkedList(); l1.add(new Name("Karl", "M")); l1.add(new Name("Stever", &quo 阅读全文
posted @ 2012-05-01 13:40 spring3 阅读(208) 评论(0) 推荐(0) 编辑
摘要: import java.util.*; public class TestCollection { public static void main(String[] args) { List<String> l1 = new LinkedList<String>(); for(int i = 0; i <= 5; i++) { l1.add("a" + i); } System.out.println(l1); l1.add(3, "a100"); System.out.println(l1); l1.set(6, &quo 阅读全文
posted @ 2012-05-01 13:11 spring3 阅读(355) 评论(0) 推荐(0) 编辑
摘要: import java.util.ArrayList; import java.util.Collection; public class Test { public static void main(String[] args) { int [] arr = {1, 2, 3, 4, 5}; for(int i : arr) { System.out.print(i + " "); } System.out.println(); Collection<String> c = new ArrayList<String>(); c.add(new St 阅读全文
posted @ 2012-05-01 10:36 spring3 阅读(247) 评论(0) 推荐(0) 编辑
摘要: import java.util.Collection; import java.util.HashSet; import java.util.Iterator; public class Test { public static void main(String[] args) { Collection<Name> c = new HashSet<Name>(); c.add(new Name("f1", "l1")); c.add(new Name("f2", "l2")); c.add 阅读全文
posted @ 2012-05-01 10:27 spring3 阅读(182) 评论(0) 推荐(0) 编辑