1 posts in topic
Flat View  Flat View

Posted By:   guru_prasanth
Posted On:   Monday, April 10, 2006 11:40 AM

I have a helper method which would return either one object or another depending on situation.One possible way of doing this is to make the return type of the method as Object and in the caller method i need to check for instance of either of the object.But i want to kniow is this a good approach.

Re: doubt

Posted By:   WarnerJan_Veldhuis  
Posted On:   Monday, April 10, 2006 04:00 PM

Well, using instanceof you can solve the problem. However, the design could use some improvements if a method returns two different objects... perhaps you can solve it using two different methods, an interface, or delegation...
About | Sitemap | Contact