Java??extends??÷???
???????????? ???????[ 2015/2/12 11:42:12 ] ????????Java ???????
??????????????????????????????????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????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11