Forums Register Login

query results into new ArrayList or not?

+Pie Number of slices to send: Send
What is better (performance or the like):

Case 1 (putting the result into a new ArrayList):




or Case 2 (setting the result without creating a new ArrayList):









+Pie Number of slices to send: Send
Why would you want to create a whole new instance if you don't have to.

Running the query, if it calls the resultList() method, it automatically returns a List that is an actual implementation of a List, most likely ArrayList. And you should always be coding to an interface anyway.

Hope that helps.

Mark
+Pie Number of slices to send: Send
okay,

so there is no need to create a new ArrayList-Instance.

thanks.

Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 963 times.
Similar Threads
Server Wide Arraylist ?
optimize read-only query in stateless session bean
new list for each iteration ?
generic List type conversions
struts2.0+java.lang.NullPointerException
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:18:19.