File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Object Creation in Static Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Object Creation in Static Method" Watch "Object Creation in Static Method" New topic
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
 
Similar Threads
Arrays are confusing
constructor acces modifiers
Class Structure in GWT Exmaple
Help Please
tester class and then some.