check the type of variable in java

check the type of variable in java
/**
 * @author lautturi.com
 * Java example: find out the type of a variable in java
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {

		int x = 5;
        System.out.println(((Object)x).getClass().getSimpleName());
        
        String str = "hello lautturi";
        System.out.println(((Object)str).getClass().getSimpleName());

	}
}
Sourc‮.www:e‬lautturi.com

output:

Integer
String
Created Time:2017-09-02 22:15:05  Author:lautturi