I am trying to know how to tell if two variables share the same primitive data type in Java. Let's say there's a method compareType() that would return true if two variables do share the same primitive data type; false otherwise.
For example,
int i = 1;
int i1 = 2;
long l = 1;
float f = 0.1f;
double d = 0.1d;
Then, compareType(f,d) will return false; compareType(i,l) will return false; compareType(i,i1) will return true;
I know in Python there is the function type() which will return something like "int", and the key component for compareType() is a function in Java that works like type() in Python. That is what I am searching for.