• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

query results into new ArrayList or not?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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):









 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay,

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

thanks.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic