Java泛型?
多年来我看到很多人都使用“泛型”这个词,老实说我不知道??它意味着什么,不管它是什么我最有可能使用它但只是不知道它被称为那个. :p
解决方法
从
http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html起
// Removes 4-letter words from c. Elements must be strings static void expurgate(Collection c) { for (Iterator i = c.iterator(); i.hasNext(); ) if (((String) i.next()).length() == 4) i.remove(); }
// Removes the 4-letter words from c static void expurgate(Collection<String> c) { for (Iterator<String> i = c.iterator(); i.hasNext(); ) if (i.next().length() == 4) i.remove(); } 对不起直接c& p,但我发现这个写作比我写的更好. 编辑以在评论中包含一个好点:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |