Quantcast
Channel: Scratch Where It's Itching
Viewing all articles
Browse latest Browse all 73

Get Simple Class Name

$
0
0
You probably heard of one method of Class that give the simple name of the class, without all the packages. Even if you hadn't, you probably know a simple way to get the sub-String following the last dot. Well, I know someone who doesn't:
publicstatic String classnameNormalize(String classname) {
		String s = new String(classname);int n;while (true) {
			n = s.indexOf(".");
			s = s.substring(n + 1, s.length());if (n == -1) {return s;
			} 
		} 
	} 


Viewing all articles
Browse latest Browse all 73

Trending Articles