JAVA中如何获取变量的类型

JAVA中如何获取变量的类型?

package xiya;

public class Demo {
	public static void main(String[] args) {
		String type = getType("123");
		System.out.println(type.substring(type.lastIndexOf('.') + 1, type.length()));
	}
	
	public static String getType(Object o) {
		return o.getClass().toString();
	}
}


Keep it simple!
作者:N3verL4nd
知识共享,欢迎转载。
原文地址:https://www.cnblogs.com/lgh1992314/p/5834727.html