Two and Three are essentially the same: You are using some sort of Factory to return the desired instance. In the latter case, you are specifying a parameter to the Factory indicating what instance you want. In the former case, youare just requesting the default instance. (This could be a Singleton instance or some other algorithm to define the a default instance, such as in the case of the java.util.Calendar class upon which this example seems to be based, an instance of the correct (locale-based) subclass of Calendar initialized to today's date). The First example is merely an object creation; it does nothing special other than create an object and call the constructor.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Not quite. In 2, a static factory method has been defined for Cal which returns an object which may or may not have been newly created. In 3, a Class representing the Cal class is loaded and returned. No Cal instance is created. hth, bear [ July 15, 2003: Message edited by: Bear Bibeault ]
Not quite. [ July 15, 2003: Message edited by: Bear Bibeault ]
True, but I wan't referring to the results when I said they were essentailly the same, but rather to the process/architecture used to acheive those results. And Example three results in the java.lang.String.class object, not the Cal.class object