Welcome to Dream.In.Code
Become a Java Expert!

Join 150,163 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,365 people online right now. Registration is fast and FREE... Join Now!




arrays

 
Reply to this topicStart new topic

arrays

sumlani
24 Aug, 2008 - 03:11 PM
Post #1

New D.I.C Head
*

Joined: 26 Jan, 2008
Posts: 26



Thanked: 3 times
My Contributions
What's the difference between an array class & arraylist class?
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Arrays
24 Aug, 2008 - 03:21 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
I am not quite sure what you mean by array class but if you are talking about the difference between an array and an arraylist the arraylist class has several added functions that support dynamic sizing, various methods for searching, sorting and deleting, and provides mechanisms for easy iteration. The ordinary array class doesn't offer such mechanisms or methods and is much more basic.

ArrayLists are good for handling a collection of items that may or may not be primitive data types (like custom objects) and handles expanding the array before it gets full.

Arrays in general have their size defined, are typically used with more basic types like integers, doubles, and character and when you need more space you have to create a new bigger array and copy over the values in some fashion.

However since arrays are not big objects like arraylist they can also be a bit faster and great for storing small number of basic values where you know the number of elements you need to store beforehand.

smile.gif
User is offlineProfile CardPM
+Quote Post

pbl
RE: Arrays
24 Aug, 2008 - 03:25 PM
Post #3

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(sumlani @ 24 Aug, 2008 - 04:11 PM) *

What's the difference between an array class & arraylist class?

An array has a fixed length an ArrayList can expand as required
you can append/add an element to an ArrayList not to an array

You can delete/remove an element from an ArrayList you can't from an array

Arrays are serializabled ArrayList are not but Vectors (that look a lot like ArrayList) are


User is offlineProfile CardPM
+Quote Post

sumlani
RE: Arrays
24 Aug, 2008 - 04:37 PM
Post #4

New D.I.C Head
*

Joined: 26 Jan, 2008
Posts: 26



Thanked: 3 times
My Contributions
QUOTE(pbl @ 24 Aug, 2008 - 04:25 PM) *

QUOTE(sumlani @ 24 Aug, 2008 - 04:11 PM) *

What's the difference between an array class & arraylist class?

An array has a fixed length an ArrayList can expand as required
you can append/add an element to an ArrayList not to an array

You can delete/remove an element from an ArrayList you can't from an array

Arrays are serializabled ArrayList are not but Vectors (that look a lot like ArrayList) are




Thank you, I understand it better now.

QUOTE(Martyr2 @ 24 Aug, 2008 - 04:21 PM) *

I am not quite sure what you mean by array class but if you are talking about the difference between an array and an arraylist the arraylist class has several added functions that support dynamic sizing, various methods for searching, sorting and deleting, and provides mechanisms for easy iteration. The ordinary array class doesn't offer such mechanisms or methods and is much more basic.

ArrayLists are good for handling a collection of items that may or may not be primitive data types (like custom objects) and handles expanding the array before it gets full.

Arrays in general have their size defined, are typically used with more basic types like integers, doubles, and character and when you need more space you have to create a new bigger array and copy over the values in some fashion.

However since arrays are not big objects like arraylist they can also be a bit faster and great for storing small number of basic values where you know the number of elements you need to store beforehand.

smile.gif



Thank you for your response, it was very helpful.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:49AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month