Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. public void printFieldNames()
  2. {
  3. Field[] fields = ClassName.class.getDeclaredFields();
  4. //gives no of fields
  5. System.out.println(fields.length);
  6. for (Field field : fields)
  7. {
  8. //gives the names of the fields
  9. System.out.println(field.getName());
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement