java get variable type

http‮//:s‬www.lautturi.com
java get variable type
/**
 * @author lautturi.com 
 * Java example: get the type of a variable in java 
 */

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.*;

public class Lautturi {

	public static void main(String[] args) throws FileNotFoundException {

		String str = "hello lautturi";
		
		String varType = ((Object) str).getClass().getName();
		// String varType = ((Object) str).getClass().getSimpleName();
		System.out.println(varType);
		
	}
}

output:

java.lang.String
OR
String
Created Time:2017-09-27 20:38:26  Author:lautturi