所以我有这些列表:
List<Double> myDoubList1 = new LinkedList<>();
myDoubList1.Add(100);
myDoubList1.Add(66.7);
List<Double> myDoubList=new LinkedList<>();
myDoubList.Add(3);
double g=myDoubList[0]*myDoubList1[0];//error
Run Code Online (Sandbox Code Playgroud)
但是在最后一行,它有一个错误:需要数组,但List找到错误.
为什么它给我这个错误?
您无法使用括号表示法访问列表.列表元素必须通过以下List#get方式解决:
myDoubleList1.get(0);
Run Code Online (Sandbox Code Playgroud)