阅读背景:

如何使用while循环和Iterator将我的LinkedList的内容相乘

来源:互联网 

Here is my code:

这是我的代码:

import java.util.*;

public class Multiply {
    public static void main(String[] args) {

        LinkedList<Integer>num = new LinkedList<Integer>();
        num.add("1");
        num.add("2");
        num.add("3");
        num.add("4");
        num.add("5");

        product( num );
    }

    public static void product(LinkedList<Integer> list) {
        int index = 0;
        Iterator<Integer>productw = list.iterator();
        Integer next = productw.next()

        while (productw.hasNext()) {
            index++;
            System.out.println("The product of the numbers is = " + num);
        }
    }
}
import java.util.*



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: