摘要: 在集合操作中支持以下四种输出方式:1、iterator;2、ListIterator;3、Enumeration输出;4、foreach输出只要碰到集合输出的情况,一定记得利用Iterator输出,这是最标准的输出方式Iterator三个方法:iter.hasNext(); //判断接下来是否有内容iter.next(); //读取接下来的内容iter.remove(); //删除元素,但是这里需要注意一点:List接口本身有remove()方法,如果在删除元素的过程中,使用List接口中的方法会报错的 //要用Iterator中的remove()方法小结:1、Itera... 阅读全文
posted @ 2013-10-22 00:30 502ck 阅读(144) 评论(0) 推荐(0) 编辑
摘要: list的添加元素import java.util.ArrayList ;import java.util.List ;import java.util.Collection ;public class ArrayListDemo01{public static void main(String args[]){List allList = null ;Collection allCollection = null ;allList = new ArrayList() ;// 指定操作的泛型为StringallCollection = new ArrayList() ;// 指定一个集合all 阅读全文
posted @ 2013-10-18 00:45 502ck 阅读(228) 评论(0) 推荐(0) 编辑
摘要: import java.util.regex.Pattern ;public class RegexDemo02{public static void main(String args[]){String str = "1234567890" ;// 此字符串由数字组成if(Pattern.compile("[0-9]+").matcher(str).matches()){// 使用正则System.out.println("是由数字组成!") ;}else{System.out.println("不是由数字组成!" 阅读全文
posted @ 2013-10-17 00:00 502ck 阅读(147) 评论(0) 推荐(0) 编辑