OK. Díky. Chápu. Tohle je tedy finální kód
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
public class Example {
int first, second;
String third, fourth;
static int fifth;
public Example(int first, int second, String third, String fourth) {
this.first = first;
this.second = second;
this.third = third;
this.fourth = fourth;
}
public ArrayList<String> getAllFields() {
var fields = new ArrayList<>(Arrays.asList(getClass().getDeclaredFields()));
var list = new ArrayList<String>(fields.size());
fields.stream().filter((f) -> !Modifier.isStatic(f.getModifiers())).forEach((f) -> {
try {
list.add(f.get(this).toString());
} catch (IllegalArgumentException | IllegalAccessException ex) {
System.out.println(ex.getMessage());
}
});
return list;
}
}