static{
try {
Scanner scanner = new Scanner(new FileReader("elements.csv"));
String title = scanner.nextLine();
while(scanner.hasNext()){
String[] line = scanner.nextLine().split(",");
ChemicalElement chemicalElement = new ChemicalElement(line[0],Integer.parseInt(line[1]),line[2],Double.parseDouble(line[3]),Double.parseDouble(line[4]),Double.parseDouble(line[5]),
Double.parseDouble(line[6]),Double.parseDouble(line[7]),Double.parseDouble(line[8]));
chemicalElements.add(chemicalElement);
}
//(String element, int number, String symbol, double weight, double boil, double melt, double density, double vapour, double fusion)
} catch (FileNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
public ChemicalElement(String element, int number, String symbol, double weight, double boil, double melt, double density, double vapour, double fusion){
this.number = number;
this.symbol = symbol;
this.weight = weight;
this.boil = boil;
this.melt = melt;
this.density = density;
this.vapour = vapour;
this.fusion = fusion;
}
和例外情况:
run:线程“main”Java.lang.exceptioninInitializerError at chemistry.chemistry.main(chemistry.Java:30)的chemistry.chemistry.AllElements(chemistry.Java:21)的error由:Java.lang.arrayIndexOutoFboundsexception:6 at chemistry.chemicalElementDAO.(chemicalElementDAO.Java:51)...2多时间:0秒)
试试这个。
start()
方法以脱离静态上下文import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class YourClass {
List<ChemicalElement> chemicalElements = new ArrayList<>();
public static void main(String[] args) {
YourClass yc = new YourClass();
// get out of the static context
yc.start();
}
public void start() {
try {
Scanner scanner =
new Scanner(new FileReader("elements.csv"));
String title = scanner.nextLine();
while (scanner.hasNext()) {
String[] line = scanner.nextLine().split(",");
String element = line[0];
int atno = Integer.parseInt(line[1]);
String symbol = line[2];
// Allocates an array for the remainder of the values.
// This defaults to all zeros.
// This presumes there will be no more than 9 values
// per line.
double[] values = new double[6];
for (int i = 0; i < line.length - 3; i++) {
values[i] = Double.parseDouble(line[i + 3]);
}
ChemicalElement chemicalElement = new ChemicalElement(
element, atno, symbol, values[0], values[1],
values[2], values[3], values[4], values[5]);
chemicalElements.add(chemicalElement);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
这是我所能提供的最好的信息。如果它不起作用,你应该和你的老师讨论。
我正在尝试在h264视频上添加一个png水印(带有alpha通道),它是半透明的。通过使用叠加过滤器,我成功地将水印添加到视频中。 但覆盖过滤器不提供透明选项。所以我尝试使用混合过滤器。然而,当我使用原点解析时,会出现错误消息。 输出: 结果似乎与参数有关。所以我尝试在混合之前缩放水印。 FFMPEG使用这些参数。但是输出不是我预期的,因为水印被拉伸了。任何想法混合水印与不同的分辨率,而不拉伸到视
我试过如下所示,但在两种情况下显示的时间都是相同的?我做错了什么。 “当前日期”时间显示与“12小时后”相同...
在其中声明列表后 并在类PlayListStuff中添加字段
本文向大家介绍向JavaScript的数组中添加元素的方法小结,包括了向JavaScript的数组中添加元素的方法小结的使用技巧和注意事项,需要的朋友参考一下 在数组的开头添加新元素 - unshift() 源代码: 测试结果: 在数组的第2位置添加一个元素 - splice() 源代码: 测试结果: 数组的末尾添加新的元素 - push() 源代码: 测试结果: 下面就提供一下上文中的一些函数
通过使用本文https://medium.com/@clarkjohnson_85334/adding-fetched-markers-to-my-react-native-maps-app-5f068c7be14d,我成功地在MapView中集成了观察结果。 JSON文件
如何在此查询中添加大小,因为我只需要第一个结果。