class father{
String father="father";
public String get(){
return father;
}
public String getString(){
return get();
}
}
class child extends father{
String child ="child";
public String get(){
return child;
}
}
public class othertest { public static void main(String s[]) {
child c=new child();
System.out.println(c.get());
System.out.println(c.getString());
System.out.println(((father)c).get());
System.out.println(((father)c).getString());
}
}大家都来试试吧
String father="father";
public String get(){
return father;
}
public String getString(){
return get();
}
}
class child extends father{
String child ="child";
public String get(){
return child;
}
}
public class othertest { public static void main(String s[]) {
child c=new child();
System.out.println(c.get());
System.out.println(c.getString());
System.out.println(((father)c).get());
System.out.println(((father)c).getString());
}
}大家都来试试吧
child
child
child