Java Generics in Java Generics in Java A Common Problem

is "thing" null? Object thing = contents; contents = null; return thing;

is "thing" null? First, object thing is assigned "contents". Second, "contents" is assigned null. Is "thing" now null?

Object thing = contents; contents = null; return thing;

1 Answer

Steven Parker
Steven Parker
201,997 Points

Assigning "contents" will not change "thing".
The value of "thing" will be what "contents" had before being assigned with null.