ServletConfig与ServletContext对象详解
2014-11-16 19:47
363 查看
这种多态是用抽象类实现的
学了java也有一年半了吧,也做过项目了,可是今天我无意中看到一位朋友这样用了多态,原来还有这样用,真实惭愧!!!哈哈
public class Test { /** * @param args */ public static void main(String[] args) { A a=new C(); a.f(); } } abstract class A { protected void m1(){ System.out.println("A m1()"); m2(); } protected abstract void m2(); public abstract void f(); } class B extends A { @Override protected void m2() { System.out.println("B m2"); } public void f(){ System.out.println("B f"); this.m1(); } } class C extends A { @Override protected void m2() { System.out.println("C m2()"); } public void f(){ System.out.println("C f()"); this.m1(); } }
学了java也有一年半了吧,也做过项目了,可是今天我无意中看到一位朋友这样用了多态,原来还有这样用,真实惭愧!!!哈哈
相关文章推荐
- ServletConfig与ServletContext对象详解
- Servlet知识详解(一)ServletContext对象 和 ServletConfig对象学习笔记
- mvc-servlet---ServletConfig与ServletContext对象详解(转载)
- (转)ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- javaweb基础学习(一)<ServletConfig与ServletContext对象详解>
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- [转]ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletConfig与ServletContext对象详解
- ServletContext与ServletConfig的详解及差异