Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Get the short name of the given class
     * 
     * @param clazz : Class to return the short name for
     * @return : short name of clazz
     */
    public static String getShortName(Class<?> clazz) {
        if (clazz == null) {
            return "null";
        } else {
            String name = clazz.getName();

            if (name.lastIndexOf('.') > 0) {
                name = name.substring(name.lastIndexOf('.') + 1);
            }

            return name;
        }
    }
}