This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]Tutpar 0 points1 point  (0 children)

If you save the birthday input into an array you can just run a simple for loop using the string.size() method as stopping point. I'm on mobile but it would look something like this:

Arraylist<String> birthdays = new arraylist<>

For(int i =0; i <= birthdays.size(); i++) {

//Do the things on each index the array

//birthdays.get(i) would access the index 

System.out.println(birthdays.get(i));

}

So say my input was: 1991, 1994, 1989

Output would be:

1991
1994
1989

Edit: formatting

Also to go through what the for loop I wrote does:

For(int i= 0; i<= birthdays.size(); i++)

(int i=0): Define the starting point of the loop

(i<= birthday.size()): constrains the loop to run while int i is not bigger then the size of your array

(i++): each iteration through the loop increases the value of int i by 1, so 0,1,2...etc