Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
 
friki data migration
Ranch Hand
Posts: 772
  • Mark post as helpful
  • send pies
  • Report post to moderator
(Level: beginner)

This page is (hopefully) an answer to the numerous questions we receive along the lines of "where does Java hold my variables?".

The simple answer is: It doesn't matter.

Unless you're a computer engineer, or a system architect, or a writer of Java compilers or JVMs, Java puts "things" where it thinks best - and whether that's the Stack or the Heap makes absolutely NO difference to you as a programmer.

Furthermore, Java is a memory-managed language, so the whole philosophy is that you shouldn't know - and you certainly shouldn't rely on - where it puts things, because it might change in a future release.

If you're doing a course in Computer Science theory, and you want to understand how Stack frames or heap memory works, by all means look it up - Java's definitions are not very different to other languages that use the terms (and many do).

But if you're simply learning Java as a language for programming, it's a distraction.

Create objects; use them; let the garbage-collector clean them up - it really is as simple as that.

Anything else is internal procedural "fluff", and will NOT help you become a better Java programmer.

.

Hope it helps.



CategoryWinston
 
    Bookmark Topic Watch Topic
  • New Topic