java print variable type
System.out.println(((Object)x).getClass().getName());
java print variable type
System.out.println(((Object)x).getClass().getName());
java print type of object
//Example:
Integer number = 15;
System.out.println(number.getClass().getName());
//This print to console the fully qualified name of the class, which for the example is:
java.lang.Integer
//If you want a more concise output, you can use instead:
System.out.println(number.getClass().getSimpleName());
//getSimpleName() give you only the name of the class:
Integer
//Printing the type of primitive variables is a bit more complex: see this
//https://stackoverflow.com/questions/180097/dynamically-find-the-class-that-represents-a-primitive-java-type
//for details.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us