CaptRage61
Programmer
I am trying to create an array of Element objects for use in a JTable. I am having problems creating this array and I am not sure why. Here is what I am trying to do:
Here is my Element class
Does anyone have any ideas on how to make this work???
Code:
Element e = new Element("Mercury", "Hg", 80, 200.59,356.7 );
Element[][] data = {
{e.getName(), e.getSymbol(),
e.getNumber(), e.getWeight(), e.getBP()},
};
Code:
public class Element {
String name;
String symbol;
int number;
double weight, bp;
public Element() {
}
public Element(String n, String s, int num, float w, float b){
name = n;
symbol = s;
number = num;
weight = w;
bp = b;
}
public String getName(){
return name;
}
public String getSymbol(){
return symbol;
}
public int getNumber(){
return number;
}
public double getWeight(){
return weight;
}
public double getBP(){
return bp;
}
public void readFile(){
//reads the contents of a file
}
}
Does anyone have any ideas on how to make this work???