| Author |
Object Creation in Static Method
|
Ram Adsumalli
Ranch Hand
Joined: Oct 16, 2006
Posts: 64
|
|
Hi All, In many real time applications, I observe the object creation is in the static method. And all the methods in that class will be non static. And all non static methods is used in the other classes like What is the main advantage of doing this. TO my knowledge we can do this another way also. Just make the name() method as static and use that in another class without creation of object.Realtime application code base looks like this As the constructor is public singelton advantage is also ruled out. Thanks, Ram
|
 |
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
From what I can see, the only difference is, you have two different ways of calling the getname() function If you want to reference the getname method non-statically, you're going to have to create an instance of that class, where as in the first example you use only static methods, so you don't. Justin Fox [ February 22, 2008: Message edited by: Justin Fox ]
|
You down with OOP? Yeah you know me!
|
 |
 |
|
|
subject: Object Creation in Static Method
|
|
|