Thor
Thor

Reputation: 10028

is there a keyword in java that's similar to swift's dynamicType

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

Answers (1)

Thilo
Thilo

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

Related Questions