??????????????????????????????????Java?У????keywordextends?????????е???????е?????????(????????)???μ?????????(??????)????Java?в??????С?
??????1?????
class Animal{
void eat(){
System.out.println("Animal eat");
}
void sleep(){
System.out.println("Animal sleep");
}
void breathe(){
System.out.println("Animal breathe");
}
}
class Fish extends Animal{
}
public class TestNew {
public static void main(String[] args) {
// TODO Auto-generated method stub
Animal an = new Animal();
Fish fn = new Fish();
an.breathe();
fn.breathe();
}
}
??????eclipse???е??
????Animal breathe!
????Animal breathe!
????.java??????????????????bin??????????????.class????????н????????????????????????????
??????2??????
class Animal{
void eat(){
System.out.println("Animal eat");
}
void sleep(){
System.out.println("Animal sleep");
}
void breathe(){
System.out.println("Animal breathe");
}
}
class Fish extends Animal{
void breathe(){
System.out.println("Fish breathe");
}
}
public class TestNew {
public static void main(String[] args) {
// TODO Auto-generated method stub
Animal an = new Animal();
Fish fn = new Fish();
an.breathe();
fn.breathe();
}
}
???????н????
????Animal breathe
????Fish breathe
???????????ж????????????????????????????????????????????????????????????????????????????????????????????super????????????