what is garbage value?

India
July 12, 2009 12:20am CST
I am newbie to Java What is actually garbage value?I am using netbean IDE .
2 responses
@sujal0211 (224)
• India
15 Jul 09
when we declare a variable, let say "int x",in this case we have not assign any value to x.When we write "int x" ,a pointer is assigned in your memory equal to size of int(dont bother).If that memory place has a value from your last program's calculation then this "x" will be assigned that value ,stored in your memory. THIS VALUE IS CALLED "GARBAGE VALUE"
@mr_mlk (364)
20 Jul 09
You appear to be talking about C++ rather than Java. For a start "int x" will not create a "pointer". What it will do will depend on the scope. Object scoped will be on the heap, and will be an off-set to the objects reference. Method scope and it will be put on the stack. The default value in Java is not taken from the last value store in that location in memory. Again the value depends on the scope. Object scope and the value will be zero. Method scope and it is "undefined" and can not be used until it has been defined. "Garbage Value" has no meaning in Java.
• India
12 Jul 09
Though the Garbage Value concept is, but it never comes for us to define it or use this. It can be said that after a execution of a program end the memory references still persist and the values u supplied for execution of program still rests in memory untill the JVM or OS makes a Garbage Collection. ie it refreshes the memory area and put this for using it again.