classname - How to extract the name of all classes in a normal String from java class? -


public class {      public class b{          public class c {          }      }      public class d {      } } 

if example how write java code names of classes a,b,c , d in string. highly appreciated. thank you

i came reflection based answer:

public static list<string> getclassnames(class baseclass) {     list<string> classnames = new arraylist<string>();     classnames.add(baseclass.getsimplename());     (class subclass: baseclass.getclasses()) {         classnames.addall(getclassnames(subclass));     }     return classnames; } 

which returned [a, d, b, c]. didn't make clear if order important.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -