public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException { Hello hello = new Hello(); Field linesField = Hello.class.getDeclaredField("lines"); linesField.setAccessible(true); List<String> lines = (List<String>) linesField.get(hello); for (String line : lines) { System.out.println(line); } }更方便的方法:org.apache.commons.lang3.reflect.FieldUtils.readField(object, fieldName, true);
更方便的方法: