package day6;
class Typist
{
public void type()
{
System.out.println("typing!!!!");
}
}
class Coder extends Typist
{
public void type()
{
System.out.println("typing quickly!!!!");
}
public void code()
{
System.out.println("coding!!!!");
}
}
public class test07 {
public static void main(String args[])
{
Typist typist = new Coder();
//typist.type();
//run(new Coder());
//Coder coder = new Typist();
typist.type();
if(typist instanceof Coder)
{
Coder coder = (Coder)typist;
//typist.code();
coder.code();
System.out.println("......");
}
Typist typist1 = new Typist();
Coder coder1;
if(typist1 instanceof Coder)
coder1 = (Coder)typist1;
}
static void run(Typist typist)
{
typist.type();
}
}
day6 test07
最新推荐文章于 2022-11-10 17:58:06 发布