Skip to content

Instantly share code, notes, and snippets.

@ldclakmal
Created May 28, 2017 16:26
Show Gist options
  • Save ldclakmal/4e78d54a439e86013c8650dd49e65372 to your computer and use it in GitHub Desktop.
Save ldclakmal/4e78d54a439e86013c8650dd49e65372 to your computer and use it in GitHub Desktop.
Get the names of the static variables of a class
public void getVariableNames() {
Field[] fields = MyClass.class.getDeclaredFields();
for (Field f : fields) {
if (Modifier.isStatic(f.getModifiers())) {
System.out.println(f.getName());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment