• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is Collection.I will provide an example please correct me, if i am wrong  RSS feed

 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per my understanding i am framing an example for a collection.Please correct me if i am wrong?


Collection is like a plastic bag where you can easily insert fruits,vegetables or other objects.

But the size of collection is dynamic.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:
Collection is like a plastic bag where you can easily insert fruits,vegetables or other objects.

If it is a pre - generics collections.
Vishal Hegde wrote:
But the size of collection is dynamic.


Yea, but, we can defined the size in the beginning.
 
Naresh Shanmugam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real advantage of collections over array is, it is dynamic(Not necessary to specify the size in advance). But Collections does allow to specify the size in advance(during declaration), is there any difference/[b]significance[/b] if the size of the collection is specified during the declaration time.

 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The difference is that filling a Collection whose capacity is already sufficient for the expected contents is faster than filling and repeatedly enlarging one.

I suggest you go through the Java™ Tutorials section.
 
Naresh Shanmugam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your prompt response Campbell i got the point...
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can you please provide me with a simple collection example
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't tell me you could find absolutely nothing at the page Campbell linked to.

Well, you can, but I just won't believe you.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:You can't tell me you could find absolutely nothing at the page Campbell linked to.

Well, you can, but I just won't believe you.
I presume you have actually read that page, Vishal Hegde?
 
thiru maram
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
collection is a container which can hold a group of objects of any type and can grow dynamically based on its memory allocation management.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch thirupathi maram
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!