Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Differences between an Array and Collection

Posted on 2006-11-22
5
Medium Priority
?
3,874 Views
Last Modified: 2008-01-09
May i know what is the differences between an Array and Collection? Thank you.
0
Comment
Question by:retkehing
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17997057
An array is inherently fixed in size, whereas a Collection can grow. That's the most important difference
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 120 total points
ID: 17997850
And: in an array the values are side by side,
a collection will scatter the values to positions where they are most convenient.
Every collection has its pro's and con's.
E.g.: linked lists can insert an item quickly but are a drag to sort.

;JOOP!
0
 
LVL 6

Expert Comment

by:SamsonChung
ID: 17999157
Arrays a basic structures. for example, an array of integers means every single insert in there is an integer.

while in collection, you don't have that limitation.

you can have first object being an integer, 2nd being a String, 3rd being a string, 4th being an INTEGGER..

noticed, string and INTEGGER are not typos, they are custom classes you can define.

0
 
LVL 24

Expert Comment

by:sciuriware
ID: 18001058
SamsonChung, what would you say about this code piece?

     Object[] array = new Object[4];

     array[0] = "12345";
     array[1] = new Integer(6);
     array[2] = new Exception("Also!");
     array[3] = this;

???

;JOOP!
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question