惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 【当耐特】
The Cloudflare Blog
B
Blog
Last Week in AI
Last Week in AI
小众软件
小众软件
量子位
S
SegmentFault 最新的问题
V
Visual Studio Blog
博客园 - 叶小钗
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
A
About on SuperTechFans
雷峰网
雷峰网
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler

博客园 - Ring

运行Java cmd程序 找不到或无法加载主类怎么解决 Generics and Collection (2) mybatis, spring, springmvc 什么时候该用NoSQL? 如何学习Javascript 好文章尽收眼底 事务和锁 索引 VS调试Javascript. Asp.net常用状态管理方案分析 .NET中的缓存知识总结 "The server has rejected the client credentials"解决方案 - Ring 有关IIS7概述以及配置和开发的几篇文章摘录 CodeForFun--编写自动登录Email的程序 是什么使得我的进程崩溃了? OutOfMemory这家伙是谁?为什么我还留有许多内存,它却使进程崩溃了? ASP.NET 崩溃-SiteMap中疯狂的循环 何时.NET中AppDomain会回收? .NET如何使用内存---餐馆案例分析
Generics and Collection (1)
Ring · 2015-05-02 · via 博客园 - Ring
 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);
    }
}