|
-
Nov 8th, 2004, 11:44 AM
#1
Thread Starter
Fanatic Member
Today
in computer science, someone asked if arrays could be resized in java.
The instructor answered that arrays had to have a fixed size in all languages.
I had to try very hard not to laugh.
Don't pay attention to this signature, it's contradictory.
-
Nov 8th, 2004, 11:45 AM
#2
Frenzied Member
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Nov 8th, 2004, 12:09 PM
#3
Frenzied Member
They do.
An array is a block of memory. When you 'resize' an array you create a new block of memory of the appropriate size and copy the old block into the new one and change a few pointers.
I hope you didn't make a fool of yourself
-
Nov 8th, 2004, 12:14 PM
#4
Some arrays will allow you to dynamically resize them without the full copy of the old array (such as the ArrayList in .NET), but the array is still a fixed size at any given time.
Brad!
-
Nov 8th, 2004, 12:18 PM
#5
Frenzied Member
One assumes, being a list, that it maintains a linked list to each element and simply points at the new memory block when you extend the array.
When I said 'array' I meant elements ordered in memory and accessed through array arithmetic; not a list.
Is the ArrayList of one dimension?
-
Nov 8th, 2004, 12:27 PM
#6
Originally posted by yrwyddfa
One assumes, being a list, that it maintains a linked list to each element and simply points at the new memory block when you extend the array.
When I said 'array' I meant elements ordered in memory and accessed through array arithmetic; not a list.
Is the ArrayList of one dimension?
It works (on the outside) just like an array. This means it can be multi-dimensional. You are correct in that on the inside it is a list, which is what allows it to be resized without the need to be copied. This gives it speed over standard arrays, which work as yrwyddfa stated -- a full copy of the original if you resize.
< I took the following out because I thought it was too techie >
ArrayLists are going to be done with generics in .NET 2.0. Generics are like templates in C++ (but aren't the same).
-
Nov 8th, 2004, 12:28 PM
#7
Frenzied Member
Good idea, really. The boys at M$ have been thinking
-
Nov 8th, 2004, 12:29 PM
#8
Frenzied Member
Generics are similar to -- but not the same as -- templates in C++.
. . . and are the same as 'generics' in Ada.
-
Nov 8th, 2004, 12:33 PM
#9
Thread Starter
Fanatic Member
This has an interesting application to my personal identity in Philosophy class.
I would argue that it's the 'same' array because it has the same data (and context for that data) (same mind) but you argue it isn't because it is stored in another area (different body).
Don't pay attention to this signature, it's contradictory.
-
Nov 8th, 2004, 12:56 PM
#10
Lively Member
Originally posted by alkatran
This has an interesting application to my personal identity in Philosophy class.
I would argue that it's the 'same' array because it has the same data (and context for that data) (same mind) but you argue it isn't because it is stored in another area (different body).
I'd love to se the face of your teacher after you say that.
Last edited by Xcoder : 09-10-2001 at 12:45 AM.
-
Nov 9th, 2004, 04:17 AM
#11
Frenzied Member
The syntax is the same, but semantically they are different. It's simply an abstraction of a linked list to make it look like an array.
All of the problems associated with linked lists will still be there, and element access will be slower than standard array element access. The only bit that will be faster is resizing.
-
Nov 9th, 2004, 07:02 AM
#12
PowerPoster
-
Nov 9th, 2004, 07:04 AM
#13
Your tutor is correct, arrays are static. Runtime arrays are dynamic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|