Solved

Differences between an Array and Collection

Posted on 2006-11-22
5
3,870 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 30 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
by zero exception 10 83
What's wrong with this code? 4 47
Given a github repo find email address of all collaborators in that repo 1 56
Java import explained 4 49
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

752 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