逐步命名对象

时间:2012-03-19 22:34:07

标签: object naming

我想知道每次运行方法时如何命名不同的新对象

public class Horse extends Animal{
int horsenum = 0;

}
public  void reproduce(Horse h){
    horsenum ++;
    Horse newHorse = new Horse(); //Here is where I would like to name the new horse "newHorse1, newHorse2, etc."

1 个答案:

答案 0 :(得分:0)

添加Horse.Name ofType字符串的属性,并将其命名为...