dynamic memory allocation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • New

    dynamic memory allocation

    I am new to java and was wondering does java have dynamic memory allocation
    like in C (malloc, calloc)

    Thank you


  • Liz

    #2
    Re: dynamic memory allocation

    yes, it is called "new"

    "New" <a@a.co> wrote in message news:4084f61f$1 _1@news.iprimus .com.au...[color=blue]
    > I am new to java and was wondering does java have dynamic memory[/color]
    allocation[color=blue]
    > like in C (malloc, calloc)
    >
    > Thank you
    >
    >[/color]


    Comment

    • Raymond DeCampo

      #3
      Re: dynamic memory allocation

      New wrote:[color=blue]
      > I am new to java and was wondering does java have dynamic memory allocation
      > like in C (malloc, calloc)
      >[/color]

      Yes and no. As in, yes, Java does dynamic memory allocation and no, it
      is not like C.

      The main difference is that memory allocated in C with malloc() and
      friends must be freed or memory leaks will result. Java has automatic
      garbage collection, making it much more difficult to create memory leaks.

      Consult your favorite Java text on the new operator.

      Ray

      Comment

      Working...