Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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.
Comment

PREVIOUS NEXT
Code Example
Java :: android internet permission 
Java :: create file android java specific folder 
Java :: org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder 
Java :: how to byheart faster 
Java :: check java version 
Java :: map java get first key 
Java :: spring get bean with generic type 
Java :: array ausgeben java 
Java :: java int to binary 
Java :: java trim method 
Java :: why java is popular 
Java :: add extension quarkus 
Java :: how to create a item in minecraft modding 
Java :: infinity constatn in java 
Java :: JAVA_HOME is not defined correctly. 
Java :: android studio get string 
Java :: org.mockito.exceptions.misusing.WrongTypeOfReturnValue 
Java :: get first 5 characters of string java 
Java :: arraylist string to string array 
Java :: spigot execute command as player 
Java :: spring @Bean destroyMethod 
Java :: into to string in java 
Java :: find if a value is in a 2d array java 
Java :: array string remove element java 
Java :: java run shell command 
Java :: how to print multiple lines in java 
Java :: convert int array to Integer list java 
Java :: how to set list data to android spinner 
Java :: get random word from list java 
Java :: solid principles in programming 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =