interface Product { } class Product1 implements Product{ } class Product2 implements Product{ } public class SimpleFactory { public static Product createProduct(String productname) { if (productname == "1") { return new Product1(); } else if (productname == "2") { return new Product2(); } else { return null; } } }