Skip to content

Instantly share code, notes, and snippets.

@bananu7
Created February 23, 2016 14:42
Show Gist options
  • Save bananu7/67d63ff407579953414c to your computer and use it in GitHub Desktop.
Save bananu7/67d63ff407579953414c to your computer and use it in GitHub Desktop.
package com.company;
abstract class A {
public abstract void hello();
}
abstract class B extends A {
}
class C extends B {
public void hello() {
System.out.println("hello world");
}
}
interface IFactory {
A factorize();
}
abstract class AbstractFactory implements IFactory {
String dup(String s) {
return s + s;
}
}
class CFactory extends AbstractFactory {
public A factorize() {
return new C();
}
}
class HelloFacade {
public void hello() {
IFactory f = new CFactory();
A a = f.factorize();
a.hello();
}
}
public class Main {
public static void main(String[] args) {
HelloFacade f;
f.hello();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment