现在的位置: 首页 > 综合 > 正文

没有用extends继承,用super怎不会出错?

2013年08月10日 ⁄ 综合 ⁄ 共 265字 ⁄ 字号 评论关闭

class Wrapping
{
private int i;
public Wrapping(int x){
i=x; }
public int value(){
return i; }
}
public class Parcel
{
public Wrapping wrap(int x)
{
return new Wrapping(x){
public int value(){
return super.value()*47;
}
};
}
public static void main(String[] args)
{
Parcel p=new Parcel();
Wrapping w=p.wrap(10);
}
}

抱歉!评论已关闭.