几经挫折,终于知道错哪里了
       源程序中的temp==it.next() 改为 temp.equals(it.next()) ,经过查网上的相关资料,错误原因
是由于没有分清楚比较两个字符串(String)时,使用 '==' 运算子和java.lang.String.equals()的不同。
下面是二者的具体区别。
       '=='这个运算子会看看这两个字符串的references是不是指向同一个字符串object。而java.lang.String.equals()这个method则会比较这两个字符串的"值"是不是一样的。换句话说,比较这两个字符串是不是有相同的字符序列。 
       当使用String literals(一串被双引号括住的字符)时,使用 '=='运算子和使用equals method 的结果会是一样的。所有的String literals都是指向同一个String 类别的instances。系统中有一个pool,当有新的String literals出现时,系统会先去检查pool 之中,是不是已经存在一个和这个新的String literals有相同内容的对象。如果存在, 则会传回一个指向这个此物件的reference。若不存在,则会将此String literals放到 pool中,然后传回这个对象的reference。 
举个例子: 
String s1 = "hello"; 
String s2 = "hell"+"o"; 
System.out.println("Using equals op"+ (s1==s2)); //True 
System.out.println("Using equals method" + (s1.equals(s2))); //True 
当字符串是由"new"这个关键词所造出来的时候,则不是这么一回事。 
String s3 = new String("hello"); 
String s4 = new String("hello"); 
System.out.println("Using equals op" + (s3==s4)); //False 
System.out.println("Using equals method" + (s3.equals(s4))); //True 
      传用"new"这个关键词时,会造出两个不同的对象,所以会有两个不同的references,即使在底层的string literal是一样的。在上面的例子中,'=='运算子传回false,因为两个references是不同的。而equals method则传回true,因为这两个对象所代表是同样的字符序列。 
       
在我这个程序中,就是用了“==”来比较了通过new 创建出来的对象。因为it.next()迭代的就是不同
new对象,即二者的指向的内存地址不一样。程序中语句Matcher m=pw.matcher(text)返回的 m为多个对象的集合。Pattern.mattcher() 的具体实现方法是: 
public Matcher matcher(CharSequence input) {
        synchronized(this) {
            if (!compiled)
                compile();
        }
        Matcher m = new Matcher(this, input);        return m;
    }
Matcher(Pattern parent, CharSequence text) {
        this.parentPattern = parent;
        this.text = text;
        // Allocate state storage
        int parentGroupCount = Math.max(parent.capturingGroupCount, 10);
        groups = new int[parentGroupCount * 2];
        locals = new int[parent.localCount];
        // Put fields into initial states
        reset();
    }
哈哈,问题终于解决了,学习也许就是如此。要碰见问题了,才能真正学到东西 !!!