public class Anmial{
int age;
String name;
public static void main(String[] args)
{
Dog dog=new Dog();
dog.SetAge(10);
System.out.print(dog.GetAge());
}
}
class Dog extends Anmial{
float height;
void SetAge(int age)
{
this.age=age;
}
int GetAge()
{
return age;
}
}
- 内存分析
- 使用extends关键字来继承
- java只支持单继承,不支持多继承