The Reference Object application programming interface (API) is new in the Java Development Kit (JDK) 1.2. This API allows a program to maintain special references to objects that allow the program to interact with the garbage collector in limited ways. Not all programs require this level of interaction with the garbage collector. For example, a program that keeps a lot of objects in memory or a program that needs to perform cleanup operations on related objects before an object is reclaimed might be good candidates for using the Reference Objects API.
* A web-based program might display a lot of images when an end user goes to a particular page on the web. If the end user leaves the page, it is not always certain he or she will return. Such a program can use reference objects to create a situation where the garbage collector reclaims the images when heap memory runs low. In the event the end user returns to the page, the program can reload the image if it has been reclaimed.
* A program can use a reference queue to create a situation where the program is notified when a certain object is reachable only through reference objects. Upon notification, the program can proceed with clean-up operations on other related objects to make them eligible for garbage collection at the same time.
Because it is essential to understand garbage collection before you can understand how reference objects work, this article begins by describing how garbage collection works when no reference objects are involved, followed by a discussion of how things change when reference objects are added to the heap.
2006-11-27 16:43:18
·
answer #1
·
answered by srihari_reddy_s 6
·
0⤊
0⤋
When you pass a normal variable as an argument in a method, the operation inside the method can make changes to the variable as part of its function, but those changes will not affect the value of the original variable.
When you pass a variable by reference, any change in the value of the refered variable inside the method will affect the value of the variable back where the method was first called.
so if you go:
String Bob = "Fred";
ChangeBobsValue(ref Bob);
System.out.println(Bob);
to a function that in some way set 'Bob = "Bob";' then your program will output "Bob".... whereas without the ref otherwise it would still output "Fred"
2006-11-27 08:30:32
·
answer #2
·
answered by evolver 6
·
0⤊
0⤋
they are like pointers in C++. Its a way to access another variable or memory address with a variable and change the data inside the memory address. It gives a direct access to a memory address
2006-11-27 06:51:13
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋
NO. Java is a porly designed language. and particularly i dont even evaluate it a "language". i evaluate it a scripting language. It calls for a RUNTIME! javascript and vbscript require runtimes too. whats the variation :P
2016-12-13 15:13:32
·
answer #4
·
answered by ? 3
·
0⤊
0⤋