Answers for "how to determine the type of a variable in java"

3

check type of variable java

public class MyClass {
    public static void main(String args[]) {
        int x = 5;
        System.out.println(((Object)x).getClass().getSimpleName());

    }
}
Posted by: Guest on December-08-2021
5

get type of variable java

((Object) myVar).getClass().getName()
//OR
((Object) myInt).getClass().getSimpleName()
Posted by: Guest on September-20-2020

Code answers related to "how to determine the type of a variable in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language