Advertisement
fslasht

TestStaticMethod.java

Apr 25th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.49 KB | None | 0 0
  1. package test;
  2.  
  3. public class TestStaticMethod {
  4.  
  5.     static class A {
  6.         static A getInstance() {
  7.             return new A();
  8.         }
  9.  
  10.         public void say() {
  11.             System.out.println("I'm Class A");
  12.         }
  13.     }
  14.  
  15.     static class B extends A {
  16. //      static A getInstance() {
  17. //          return new B();
  18. //      }
  19.         public void say() {
  20.             System.out.println("I'm Class B");
  21.         }
  22.  
  23.     }
  24.  
  25.  
  26.     /**
  27.      * @param args
  28.      */
  29.     public static void main(String[] args) {
  30.         A.getInstance().say();
  31.         B.getInstance().say();
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement