File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collections.copy

 
Wendy Gibbons
Bartender
Posts: 1107
Eclipse IDE Oracle VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why doesn't this work



it complains the destination isn't big enough to hold the src.
but both Lists are exactly the same size?

My only thoughts are that java is fibbing and doesn't actually allocate memory for the new list at creation just goes "oh yes must remember that".

Oh yes this is in a jsp page if that makes a difference.

I have got it working by going, just want to know why i need to.
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons wrote:why doesn't this work



it complains the destination isn't big enough to hold the src.
but both Lists are exactly the same size?

My only thoughts are that java is fibbing and doesn't actually allocate memory for the new list at creation just goes "oh yes must remember that".

The new List has a capacity to store the elements (memory allocation), but it's still empty. That means it has a size of 0. Size and capacity are two very different things. The only thing that you can say about them is that the capacity is never smaller than the size.
 
Wendy Gibbons
Bartender
Posts: 1107
Eclipse IDE Oracle VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh yes, thank you.
Just reading the source now to answer my other questions about why this matters as collections grow as you add items to them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic