其他分享
首页 > 其他分享> > 低级错误

低级错误

作者:互联网

 1 public class Hero {
 2     private int age;
 3 
 4     public int getAge() {
 5         return age;
 6     }
 7 
 8     public void setAge(int age) {
 9         this.age = age;
10     }
11 
12     public static void main(String[] args) {
13         Hero hero= new Hero();
14         var heros = new Hero[10];
15         for(int i = 0; i < heros.length; i++){
16             hero.setAge(i);
17             heros[i] = hero;
18         }
19     }
20 }

 

标签:Hero,错误,int,age,低级,heros,hero,public
来源: https://www.cnblogs.com/yxcling-cn/p/13855767.html