consider am declaring a variable avar as
Set avar;
then ,i initialized as
avar= new HashSet();
now if i out this avar class…
System.out.println("class----->"+avar.getClass());
System.out.println("class name--->"+avar.getClass().getName());
System.out.println("class--super name--->"+avar.getClass().getSimpleName());
System.out.println("is interface--->"+avar.getClass().isInterface());
It output is :
class----->class java.util.HashSet
class name--->java.util.HashSet
class--super name--->HashSet
is interface--->false
Is it Possible to get the variable type as Set….
i mean the expected out is Set ……..
The type of the variable is
Set. The type of the object that the value of the variable refers to isHashSet.You can’t get the type of the variable if you’ve only got the value (e.g. if this value is received by a method as a parameter).
This goes back to your earlier questions – it’s still not clear to me that you’ve really understood my answers there…