Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object Creation in Static Method

 
Ram Adsumalli
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic