public static void main(String[] args) { Ticket ticket = new Ticket(); ticket.setAddress("address00"); ticket.setCity("city00"); ticket.setPhone("phone00"); ticket.setPoil("poi00"); ticket.setTitle("title00"); Field[] fields = ticket.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true);//这行是必须的 try { System.out.println(field.get(ticket).toString()); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } }