For example I have this variablevar
int var=200;
How can I know what type is a variable ( int
, String
, boolean
...)?
Since if I print it I don't know if it's a int
or a String
(in this case).
For example I have this variablevar
int var=200;
How can I know what type is a variable ( int
, String
, boolean
...)?
Since if I print it I don't know if it's a int
or a String
(in this case).
Another way to do it, without having to create the variable with a wrapper, would be to put
Object
something like this at the time of obtaining the class name:Departure:
It would work for non-primitive types as well:
Departure:
You can use
Wrappers
instead of primitive types, for example for your case instead ofint
you would useInteger
.In the output you would get the following:
Here is a table of primitive types and their equivalents in
Wrappers
: