Android examples for java.lang.reflect:Class
Get the short name of the given class
/*/*ww w .j a va 2 s .c o m*/ * ClassUtil.java * * Avaya Inc. - Proprietary (Restricted) Solely for authorized persons having a * need to know pursuant to Company instructions. * * Copyright 2013 Avaya Inc. All rights reserved. THIS IS UNPUBLISHED * PROPRIETARY SOURCE CODE OF Avaya Inc. The copyright notice above does not * evidence any actual or intended publication of such source code. */ //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; } } }