java - 如何创建一个新变量来存储在 ArrayList 中?

标签 java arraylist double

我想在 ArrayList 中存储一个值,但我该怎么做?

这是我的代码:

public class JavaTutorials{

    static double cor = 3.90000231;

    static double result = 0;

    static ArrayList<Double> chilist = new ArrayList<>();
    static ArrayList<Integer> ilist = new ArrayList<>();

    public static void main(String[] args) throws InterruptedException{
        int j;
        for(j = 0; j <= 999999999; j++){
            result = result * cor + j;
        }
    }
}

谢谢。

最佳答案

public static void main(String[] args) throws InterruptedException{
    int j;
    for(j = 0; j <= 999999999; j++){
        result = result * cor + j;
        chilist.add(result)
    }
}

类似这样的东西吗?

关于java - 如何创建一个新变量来存储在 ArrayList 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36158478/

相关文章:

java - 为什么最后一个数字不对?

java - 如何正确初始化在单独方法中创建的变量,以便在另一个方法中使用?

java - 如何使用选项检查标签是否已选中

java - Try catch 没有捕获错误的数字输入(还得到 java.lang.arithmatic 异常/零)

Java 递归通过 ArrayList 中的引用传递

C++ atof.如何检查输入错误?

协助创建 XSD 的 Java 库?

java - 存储常量的最佳方式,无论是枚举还是数据库表,都要牢记国际化

android - 从 ArrayList<CustomClass> Android 中删除重复项

java - double 的最大整数值