0

Let's say I have the following:

AtomicReference < String> tmpRef_nullStr = new AtomicReference < String>(null);

and

AtomicReference < String> tmpRef_helloStr = new AtomicReference < String>("hello");

Is there a way to check the type of these AtomicReferences so that in both cases returns a type of String?

Greg
  • 1
  • 1
  • I don't understand the question. Can you clarify? – shmosel Apr 27 '17 at 19:55
  • At runtime; these both have a type of `AtomicReference` not String. – Peter Lawrey Apr 27 '17 at 20:05
  • 1
    I'm looking for a way to check the type of the object that the AtomicReference holds. – Greg Apr 27 '17 at 20:12
  • 1
    Are you also trying to find the class type of null variables? That might just be NullPointerExceptions, as described by http://stackoverflow.com/questions/5712881/type-of-reference-type-with-value-null – Funny Geeks Apr 27 '17 at 20:14
  • No. If I have AtomicReference < String> ref_str = new AtomicReference < String>(null) then if I ask ref_str.get() == null will be true. I'm wondering if there is a way to ask for the type of the object (not the value of the object) that ref_str holds, which in this case the test should return a type of String. – Greg Apr 27 '17 at 20:27
  • How could it hold anything **but** string? Are you using raw or wildcard types? – shmosel Apr 27 '17 at 20:35

0 Answers0