package m;
public class Animal {
{
System.out.println("Animal");
}
public Animal(){
System.out.println("Animal Con");
}
public void move(){
System.out.println("动物可以移动");
}
public String setValue(String a){
a = a +"dd";
String b = a;
return b;
}
}
public class Dog extends Animal {
{
System.out.println("Dog");
}
public Dog(){
System.out.println("Dog Con");
}
public void move(){
System.out.println("狗可以跑和走");
}
}
public class TestDog {
public static void main(String[] args) {
Dog b = new Dog(); // Dog 对象
b = new Dog();
}
}
第二段代码:
package m;
public class Animal {
static {
System.out.println("Animal");
}
public Animal(){
System.out.println("Animal Con");
}
public void move(){
System.out.println("动物可以移动");
}
public String setValue(String a){
a = a +"dd";
String b = a;
return b;
}
}
public class Dog extends Animal {
static {
System.out.println("Dog");
}
public Dog(){
System.out.println("Dog Con");
}
public void move(){
System.out.println("狗可以跑和走");
}
}
public class TestDog {
public static void main(String[] args) {
Dog b = new Dog(); // Dog 对象
b = new Dog();
}
}