java this和super理解

最近做项目碰到super问题的理解,super是默认的

class B{
public B(){
System.out.println("PPPPPP");
}
public B(byte b){
System.out.println("BBBB");
}
public void f(){
System.out.println("fly");
}

}
public class A extends B{
public A(){

System.out.println("oooooo");

}
public A(byte r){
//super(r);
this();
System.out.println("LLLLLL");

}
public void g(){
System.out.println("LLLLLLqqqqq");
super.f();

}
public static void main(String[] args){
A a = new A();
a.g();
byte f= 0;
A d = new A(f);
}


}

结果:

PPPPPP
oooooo
LLLLLLqqqqq
fly
PPPPPP
oooooo
LLLLLL

发布了20 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/zhuimenglushang/article/details/52515694
今日推荐