package org.nhooo.example.lang; import java.util.Calendar; import java.math.BigDecimal; public class ClassName { public static void main(String[] args) { // 获取下面的类的名称。 Class clazz = String.class; System.out.println("Class Name: " + clazz.getName()); clazz = Calendar.class; System.out.println("Class Name: " + clazz.getName()); clazz = BigDecimal.class; System.out.println("Class Name: " + clazz.getName()); } }
上面的代码片段的结果是:
Class Name: java.lang.String Class Name: java.util.Calendar Class Name: java.math.BigDecimal