Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 18:58 [java_a] air> more OverLoad.java
- public class OverLoad {
- static private Base[] arr = new Base[2];
- public static void main(String[] args) {
- arr[0] = new A();
- arr[1] = new B();
- Manager mgr = new Manager();
- for(int i=0; i < arr.length; i++) {
- mgr.test(arr[i]);
- }
- System.out.println("finished");
- }
- static class Manager {
- public void test(A arg) {
- System.out.println("A: "+arg);
- }
- public void test(B arg) {
- System.out.println("B: "+arg);
- }
- public void test(Base arg) {
- System.out.println("Base: "+arg);
- }
- }
- static interface Base {}
- static class A implements Base {}
- static class B implements Base {}
- }
- 18:59 [java_a] air> java OverLoad
- Base: OverLoad$A@33dff3a2
- Base: OverLoad$B@33f42b49
- finished
- 18:59 [java_a] air>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement