我不知道如何把这个,但即时通讯试图获得在一个字段中的值的价值。下面是一些代码(不要问我为什么长度和高度):Java - 在领域获得价值?
//person class
public person(double w, double h, double l){
this.width = w;
this.height = h;
this.length = l;
}
//age class (extends person)
public age(double w, double h, double l, int a) {
super(w, h, l);
this.age = a;
}
//Creating the objects and putting them in an array (in the main class):
public person steve = new age(36.64, 185.64, 44.4, 26);
public person paul = new age(45.64, 178.64, 53.4, 47);
person[] people = new person[2];
people[0] = steve;
people[1] = paul;
现在我需要得到人们的年龄在数组中。你会怎么做?
为什么你创建一个具有年龄构造函数的人? – habsq
你的年龄在哪里?似乎它延伸人,它有getters,setters?发布代码 – developer
*仅供参考:* [Java命名约定](http://stackoverflow.com/documentation/java/2697/oracle-official-code-standard/9031/naming-conventions#t=201611272151346697502)适用于类名以大写字母开头,即'Person'和'Age'。 – Andreas