abstract
package study.test;
/**
* @see 抽象类One
* @author FenglinZ
* @version 1.0
*/
public abstract class AbsOne {
/**
* @see 获取字符
* @return 获取的字符
*/
public abstract String getString();
/**
* @see 显示获取的字符
*/
public void Show() {
System.out.print("Show:");
System.out.println(getString());
}
}
-----------------------------------------
package study.test;
public class Two extends AbsOne {
@Override
public String getString() {
return this.getClass().getName();
}
}
--------------------------------------------
package study.test;
public class Three extends AbsOne {
@Override
public String getString() {
return this.getClass().getName();
}
}
--------------------------------------------
package study;
import study.test.AbsOne;
import study.test.Two;
import study.test.Three;
/**
* @see 执行程序
* @author FenglinZ
* @version 1.0
*/
public class Execute {
/**
* @see 执行程序
* @param args
* 参数
*/
public static void main(String[] args) {
AbsOne abs = null;
abs = new Two();
abs.Show();
abs = new Three();
abs.Show();
}
}