Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Purpose: JComboBox to list down ages that a user can select

I realize that I need an array of integers. What part of the Math functions in Java will allow me to easily do that? The list of numbers will be from 1-100 in sequential order.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
161 views
Welcome To Ask or Share your Answers For Others

1 Answer

I don't quite understand why you need the Math functions.

This would work:

List<Integer> age = new ArrayList<Integer>();
for (int i = 1; i <= 100; ++i) {
    age.add(i);
}
JComboBox ageComboBox = new JComboBox(age.toArray());

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...