问java程序题!3Q

某程序中定义了一个类ChildrenAge,该类定义了三个成员,如下图所示,其中,ages为某班级小明友的年龄值数
组,setAges.方法用于对该数组进行初始化,findMaxAge方法用于查找数组中最大的年龄值.并返回该值
请写出setAges、findMaxAge方法的代码体,
class ChildrenAge(
使得程序满足上述功能要末
int ages[];
public void setAges(int [ages){
public int findMaxAge()


public class ChildrenAge {

    private int[] ages;

    public int findMaxAge() {
        if (ages == null || ages.length == 0) {
            throw new IllegalArgumentException();
        }
        return ages[ages.length - 1];
    }

    public int[] getAges() {
        return ages;
    }

    /**
     * 初始化并按照从小到达排序
     * @param ages
     */
    public void setAges(int[] ages) {
        this.ages = ages;
        Arrays.sort(ages);
    }
}
class ChildrenAge {
    int ages[];

    public void setAges(int[] ages) {
        this.ages = ages;
    }

    public int findMaxAge() {
        int max = 0;
        if (this.ages.length > 0) {
            for (int i : this.ages) {
                if (max < i)
                    max = i;
            }
            return max;
        } else
            return 0;

    }
}