-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Choosing collections
PostPosted: Mon Jan 22, 2007 2:59 am 
Newbie

Joined: Mon Jan 22, 2007 2:40 am
Posts: 2
I am just starting to learn how to use Hibernate and there are a few things about Collections which I don't understand.

If I have an attribute List inside my class why do i have to initialize it with ArrayList? Can I use a LinkedList or another type of list?
Why do I have to initialize a Set with HashSet? Why a map with HashMap? etc.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 8:56 am 
Newbie

Joined: Sun Jan 21, 2007 7:21 pm
Posts: 2
Set, List are interface that you cannot instansiate, you need the concrete implementation such as HashSet, ArrayList etc.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 9:47 am 
Newbie

Joined: Mon Jan 22, 2007 2:40 am
Posts: 2
Yes, I understand but if I have a List interface attribute in my class can I initialize it with LinkedList (concrete implementation) instead of an ArrayList? I made a very simple example using a LinkedList and I think it works but the book "Java Persistence with Hibernate" says that if I use List interface I have to initialize it with an ArrayList.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.