1 public static void main(String args[]) {
 2         List ints = Arrays.asList(new Integer[]{new Integer(1), new Integer(3)});
 3         int s =0;
 4         for(Iterator it = ints.iterator(); it.hasNext();)
 5         {
 6             int n = ((Integer)it.next()).intValue();
 7             s+=n;
 8         }
 9         System.out.println(s);
10     }

 

public static void main(String args[]) {
        List<Integer> ints = Arrays.asList(1,2,3);
        int s = 0;
        for(int n: ints)
        {
            s+=n;
        }
        System.out.println(s);
    }

 

public static void main(String args[]) {
        List<String> words = new ArrayList<String>();
        words.add("Hello");
        words.add("world");
        String s = words.get(0) +words.get(1);        
        System.out.println(s);
    }

 

package cn.galc.test;

import java.util.*;
 
class Lists{
    public static <T> List<T> toList(T[] arr)
    {
        List<T> list = new ArrayList<T>();
        for (T t: arr)
        {
            list.add(t);
        }
        return list;
    }
}
 
public class Test {     
    public static void main(String args[]) {
        List<String> words = Lists.toList(new String[]{"sun","ming"});
        for(String s:words)
            System.out.println(s);
    }
}