Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

return type of get method for CMR field  RSS feed

 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

The spec says that the get method of CMR field's should return Collection or Set. I am hoping that means any subclass of Collection or subclass of Set. So returning a List object should be OK, assuming the get method has declared return type as Collection or Set.

Thanks.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes , you could retutn List.
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mini,

Collection & Set are interfaces. End of the day, you've to choose an implementing class to hold your objects. So any implementing classes of Collection or Set should work.

HTH.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!