Dynamic Array

Discussion in 'Programming' started by weknowtheworld, Apr 19, 2007.

  1. #1
    Hi,

    What is a Dynamic Array and how is it used?

    Please do reply.. :)
     
    weknowtheworld, Apr 19, 2007 IP
  2. B.EAGLE

    B.EAGLE Guest

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I know in Java Programming that what is identified Dynamically is created in memory at execution time and what is identified Statically is created at compilation time.

    about arrays:

    arrays in java can be created only dynamicly using keytearm (new):
    Syntax:

    Type identifier[] = new Type[size];

    ex:

    int array[] = new int[5];

    if you have further questions? am ready to answer from what I know...
     
    B.EAGLE, Apr 24, 2007 IP
  3. Jim_

    Jim_ Peon

    Messages:
    72
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    A dynamic array can also refer to an array without a defined size.
     
    Jim_, Apr 24, 2007 IP
  4. B.EAGLE

    B.EAGLE Guest

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yeah that's right for example:

    String array[] = new String[];

    but what I mean is that Dynamic comes always with key word (new).
     
    B.EAGLE, Apr 26, 2007 IP
  5. Jim_

    Jim_ Peon

    Messages:
    72
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The use of the word 'new' has nothing to do with dynamic arrays. Other languages have different syntax for creating dynamic arrays. In PHP, a simple line like $myarray = array(); is used. In JAVA, all objects are declared with the keyword new. (with the exception of the primitive data types, String, and Arrays formed with braces)

    A dynamic array is an array without a defined size. One that grows automatically to make room for more data.

    A fixed-size array who's size is determined at runtime (JAVA example: String[] mywords = new String[size]; where size is an integer value determined during runtime) is a 'dynamically-allocated array'. They're different.
     
    Jim_, Apr 26, 2007 IP