api java 5 more: should i relapse an array collection?


in idea , i face identical doubt nearing . (yes, i know, ;-) ).



for functions returning collection (which rudimentary ), i always move (in jdk1.4.2) returning an array instead general list, because:




  • it enforces returning form (myobject[] instead list objects, many some-more type-safe stationary -- 'compilation' -- level)

  • it suggests 'read-only' impression returned collection (it some-more difficult supplement an component collection, even nonetheless severe 'read-only' keyword c#). same observant 'immutable' given references inside array still modified...



of course, i always create returned array (i arrangement any 'internal' array)



now, jdk5 more, i list<myobject> i wish to.



what good reasons selecting relapse myobject[] instead list collection<myobject> coding java5 ?



bonus, collection<myobject> used, illusory to:




  • enforce read-only charge returned collection ? (no add() remove() possible)

  • enforce an permanent aspect returned collection ? (even references collection modified)



ps: definitely have one.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members