My colleague mentioned list is the better way of doing it. So that we don't face null pointer exceptions. since we check for list.isEmpty() But I wasn't sure, thats why I am checking.
On Monday, August 4, 2014 3:42:35 PM UTC-4, Steve Gabrilowitz wrote: > > How would list.isEmpty() be better than object==null? If you never plan > on returning more than one object then it makes no sense to use a list. > On Aug 4, 2014 11:04 AM, "sweety fx" <[email protected] <javascript:>> > wrote: > >> A method is supposed to return a object when called. >> >> Which is better to implement for the method: >> 1. Is it better to have the method return an object. >> 2. Or return List<Object> where the single object is added to the array >> list. >> >> because, we can check for list.isEmpty() which is better than >> object!=null. not sure which one is better. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> <javascript:> >> To unsubscribe from this group, send email to >> [email protected] <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Android Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

