//Copy into the class named Element import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; public class Element { public int atomicNumber; public String name; public String symbol; public int group; public int periodicNumber; public String block; public String stateAtSTP; public String occurrence; public String description; public Element (String an, String n, String s, String g, String pn, String b, String sstp, String o, String d) { atomicNumber = Integer.parseInt(an); name = n; symbol = s; group = Integer.parseInt(g); periodicNumber = Integer.parseInt(pn); block = b; stateAtSTP = sstp; occurrence = o; description = d; } public static Element[] readElementsFromFile() throws IOException { //1-OPEN FILE String fileName = "P06elements.txt"; BufferedReader in = new BufferedReader(new FileReader(fileName)); //2-READ FILE String line = in.readLine(); //burn the first line (containing headers) line = in.readLine(); ArrayList al = new ArrayList(); while(line != null) { String[] e = line.split(","); Element tmp = new Element(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]); al.add(tmp); line = in.readLine(); } //3-CLOSE FILE in.close(); //Convert ArrayList to array Element[] el = new Element[al.size()]; for (int i=0; i