Dangling reference in java

Java

1 answer

Answer

1262956

2026-07-19 17:30

+ Follow

Java
Java

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.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.