I have a java form in which i have declared different variables of type string , and few variables of type string array and few are collections.
Using getdeclaredfileds of reflection api , i am getting every field of class in my field array variable.
But i want to separate the string variables into one common array.
array strings into other array and collection fields into other one.
eg: – String abc;
String def;
String[] lmn;
String[] opq;
Collection mno;
Define a utility method:
It separates the fields by type and stores them in a map.
Example usage:
Now
stringTypeMembercontains all class members (fields) that are of typeString.