上一页 1 2 3 4 5 6 7 ··· 27 下一页
摘要: //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) 编辑
摘要: import java.util.ArrayList; import java.util.Collection; public class Test { public static void main(String[] args) { Collection<Object> c = new ArrayList<Object>(); c.add("hello"); c.add(new Name("f1", "l1")); c.add(new Integer(100)); System.out.println(c.s 阅读全文
posted @ 2012-04-30 20:29 spring3 阅读(273) 评论(0) 推荐(0) 编辑
摘要: public class Test { public enum MyColor {red, green, blue}; public static void main(String[] args) { MyColor m = MyColor.red; switch(m) { case red: System.out.println("red"); break; case green: System.out.println("green"); break; case blue: System.out.println("blue")... 阅读全文
posted @ 2012-04-30 20:02 spring3 阅读(157) 评论(0) 推荐(0) 编辑
摘要: import java.io.File; public class Test { public static void main(String[] args) { File f = new File("C:/java"); listFileTree(f,0); } private static void listFileTree(File f,int level) { String preStr = ""; for(int i = 0; i < level; i++) { preStr += " "; } File[] ... 阅读全文
posted @ 2012-04-30 19:53 spring3 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 27 下一页