Bookmark Topic Watch Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic