Solved

Differences between an Array and Collection

Posted on 2006-11-22
5
3,869 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
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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 last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

713 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