使用反射技術,獲取Field集合,而後獲得集合的長度就能夠 Field[] s = A.class.getDeclaredFields(); System.out.println(s.length);get