【发布时间】:2012-03-19 22:34:06
【问题描述】:
我想知道每次运行方法时如何为新对象命名不同的名称
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."
【问题讨论】:
-
将
horsenum设为静态,它应该可以工作.. -
@MikeChristensen:你确定这会稳定吗?稳定的!格迪特?
-
@skaffman - 除非马在赛道上..那么你可能有比赛条件..