Results 1 to 13 of 13

Thread: Today

  1. #1

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    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.

  2. #2
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Did you hit him hard ?
    "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.

  3. #3
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    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

  4. #4
    ex-Administrator brad jones's Avatar
    Join Date
    Nov 2002
    Location
    Indianapolis
    Posts
    6,614
    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!
    Have you given out your reputation points today? Select the Rate This Post link to give points for good posts!
    -------------------------------------------------------------
    Brad! Jones
    Lots of Software, LLC
    (I wrote: C Programming in One Hour a Day) (Dad Jokes Book) (Follow me on Twitter)

    --------------------------------------------------------------

  5. #5
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    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?

  6. #6
    ex-Administrator brad jones's Avatar
    Join Date
    Nov 2002
    Location
    Indianapolis
    Posts
    6,614
    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).

  7. #7
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    Good idea, really. The boys at M$ have been thinking

  8. #8
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    Generics are similar to -- but not the same as -- templates in C++.
    . . . and are the same as 'generics' in Ada.

  9. #9

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    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.

  10. #10
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120
    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.

  11. #11
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    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.

  12. #12
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765



    Well, I was looking for a funny clown to try and remove the serious'ous'ness from this thread, but instead I found a pedi one with a pet monkey. Enjoy.
    Last edited by Pc_Madness; Nov 9th, 2004 at 07:07 AM.
    Don't Rate my posts.

  13. #13
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Your tutor is correct, arrays are static. Runtime arrays are dynamic
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width