JCombobox是泛型的,但是Java泛型不支持原始类型(并且
int是原始类型)。
因此,请改用
Integer数组:
Integer[] birthYear = new Integer[currentYear]; //currentYear is an int variableint inc=1;for(int i=0;i<currentYear;i++){ birthYear[i]= inc; inc++;}JComboBox<Integer> birthYearBox = new JComboBox<>(birthYear);

![用int填充JComboBox [] 用int填充JComboBox []](http://www.mshxw.com/aiimages/31/451725.png)
