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();
	}
}


posted @ 2016-01-09 09:21  N3verL4nd  阅读(460)  评论(0编辑  收藏  举报