Reputation: 10028
I know that in swift, there is a keyword called variableName.dynamicType which identify the type of which the variable belongs to. I was just wondering if there is a similar keyword in java?
Upvotes: 1
Views: 68
Reputation: 262474
There is Object#getClass
(which gives you a java.lang.Class
):
Object x = new BigInteger(123);
System.out.println(x.getClass().getSimpleName());
Upvotes: 4