Java examples for Reflection:Class Name
get Package And Class Name
//package com.java2s; public class Main { public static void main(String[] argv) { Class cls = String.class; System.out.println(getPackageAndClassName(cls)); }// ww w .j av a 2 s . com public static String getPackageAndClassName(Class<?> cls) { if (cls != null) { StringBuilder builder = new StringBuilder(); builder.append(cls.getPackage().getName()); builder.append("."); builder.append(cls.getSimpleName()); return builder.toString(); } return null; } }