Aha. Tak to mě nenapadlo. Trochu jsem to upravil
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.forEach((t) -> {
try {
list.add(t.get(this).toString());
} catch (IllegalArgumentException | IllegalAccessException ex) {
System.out.println(ex.getMessage());
}
});
return list;
}
}
Potřeboval bych vyfiltrovat static field (fifth). Jak to, prosím Vás, udělám?
Děkuji
PS. O reflexi jsem nikdy neslyšel. Proč by měla být pomalá?