Results 1 to 9 of 9
Thread: Help collections
- 12-12-2010, 08:29 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
- 12-12-2010, 08:58 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
what exactly do you mean with "copy" ?
ArrayList (Java Platform SE 6)
??
- 12-12-2010, 09:33 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
I want to copy all elements from arrayList erg to arrayList proist.
thanks for the answear
- 12-13-2010, 10:55 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Does class Ergazomenos extend or implement Proistamenos?
If not then you can't (well, I suspect you could if you cheated, but you shouldn't).
- 12-13-2010, 12:02 PM #5
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
class Proistamenos extends Ergazomenos
- 12-13-2010, 12:07 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
addAll() should work then.
- 12-13-2010, 01:11 PM #7
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
I cant use addall because erg is type of Ergazomenos and proist is type of Proistamenos
thanks anyway for your answer
- 12-13-2010, 01:35 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Yes you can.
Since Ergazomenos extends Proistamenos you can:
Because addAll() allows Collection<? extends E>...which would be Collection<? extends Proistamenos>. Which you just said Ergazomenos does.Java Code:proist.addAll(erg);
ETA: Oops. I misread your post.
It's the other way around!
In which case you have a design flaw.
- 12-13-2010, 05:29 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Collections
By Cbani in forum New To JavaReplies: 3Last Post: 02-16-2010, 02:46 PM -
Collections.sort()
By collin389 in forum Advanced JavaReplies: 11Last Post: 12-31-2009, 11:03 AM -
Collections Help
By Dr Gonzo in forum New To JavaReplies: 0Last Post: 12-07-2008, 09:15 PM -
Collections Sort
By senthil_jr in forum Advanced JavaReplies: 2Last Post: 06-04-2008, 08:11 AM -
Performance Of Collections
By thomasprabu in forum Advanced JavaReplies: 0Last Post: 01-05-2008, 11:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks