Java Programming
Google

Dangling reference in java?

789

Top Answer
User Avatar
Wiki User
Answered
2009-07-01 05:04:05
2009-07-01 05:04:05

I think you're referring to the C/C++ concept of "dangling pointers." This is when you allocate some memory to a pointer, then deallocate that memory, but don't change the pointer. This causes any attempted use of the pointer to return an unused memory address.

There is no such concept in Java, since the programmer has little to no control over how memory is allocated or freed.

The closest thing I can think of is if you're using a class such as a Reader, in which you can close the object (Reader.close()) and then still have a reference to it. But in this case (and other similar cases) attempting to use the Reader further will result in an IOException being thrown.

001
๐ŸŽƒ
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Related Questions


A dangling reference is less problematic in Java, because the garbage collector will eventually delete any object that is unreachable. So, even if one object has a reference to a second object, and the second has a reference to the first object, they would eventually be destroyed if they are unreachable from the objects referenced on the stack.A dangling reference is less problematic in Java, because the garbage collector will eventually delete any object that is unreachable. So, even if one object has a reference to a second object, and the second has a reference to the first object, they would eventually be destroyed if they are unreachable from the objects referenced on the stack.A dangling reference is less problematic in Java, because the garbage collector will eventually delete any object that is unreachable. So, even if one object has a reference to a second object, and the second has a reference to the first object, they would eventually be destroyed if they are unreachable from the objects referenced on the stack.A dangling reference is less problematic in Java, because the garbage collector will eventually delete any object that is unreachable. So, even if one object has a reference to a second object, and the second has a reference to the first object, they would eventually be destroyed if they are unreachable from the objects referenced on the stack.


No , Java does not support call by reference.


Java does not have the concept of Reference Variables. We cannot access the memory location where the data is stored in Java.


Whenever memory that was in use, and was referred to by a pointer variable, is freed, and the pointer variable is not updated accordingly (setting it to NULL, for example), the pointer variable is considerred to be a dangling pointer reference.


You can use Head First Java or Java Complete Reference to learn Java.


the best book of java is java complete Reference 2nd edition.



http://www.coderanch.com/t/399872/java/java/Difference-instance-variable-reference-variable


There is no explicit pass by value and pass by reference in Java. Internally Java does a pass by value of primitive data types like int, float etc and a pass by reference of object data types like business models or collections. This is Java's explicit behavior and we cannot influence Java to explicitly use pass by value or reference based on our wish.


The ambiguity that arises in a nested if statement due to more number of if then the number of else clauses is also as dangling else problem. a confusion is created with which if does the additional else clause match up.


Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object.


go for Java complete reference for beginners and intermediate learning. for advanced learning go for the Java black book.


Patrick Niemeyer has written: 'Learning Java' -- subject(s): Java (Computer program language) 'Learning Java' -- subject(s): Java (Computer program language), Java (programmeertaal) 'Java Reference Library on the Web'


The dangling person fell on the ground. This is a sentence which contains the word dangling.


Represents the current object (not usable in static methods).


There is a good book called Java - The Complete Reference. This would be a good place to start.


Pass by Reference does not create a copy of the data items. So, it is faster.


dangling pointer is a pointer


On the lower level of Java, a "reference" can be thought of like a pointer in C. It is essentially an integer which refers to (points to) a location in memory where the object data exists. // "button" is a reference to a JButton with a "1" on it (the object). JButton button = new JButton("1");


All primitive types (boolean, char, byte, short, int, long, float, double) plus String objects are passed by value in Java. All other objects are passed by reference.


There is no relation between reference and hascode, Java reference is unique pointer which refers an object. so each object will have a unique reference. but 2 diff object can have same hashcode.


You can't really delete a reference to an object. You can set the reference to null, which will eventually cause the garbage collector to free up the memory from that reference, but you cannot explicitly delete anything.


One antonym for dangling is anchored.


The man was dangling from the bridge for his life


dangling gerund is a form of verb that act as noun......



Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.