class MyObject {
private final String name;
private final String uuid;
}
how to get all fields from given objects if they are not null?
This code fails on f.get("")
with
cannot set final String field name...
when the field is null
Arrays.stream(object.getClass().getDeclaredFields())
.forEach(f -> {
try {
f.setAccessible(true);
system.out.println(f.getName() + ":" + f.get(""));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
Aucun commentaire:
Enregistrer un commentaire