get Short Java Name - Java Reflection

Java examples for Reflection:Class Name

Description

get Short Java Name

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        Class c = String.class;
        System.out.println(getShortJavaName(c));
    }//w  ww. ja  v a 2  s  . co m

    public static String getShortJavaName(Class<?> c) {
        String[] split = c.getName().split("\\.");
        return split[split.length - 1];
    }
}

Related Tutorials