how to select data from a list sequentially and then print it one string at a time [on hold]

58
August 12, 2019, at 9:50 PM

sorry im a noob but

lets say i have a list of strings called emailList

List<String> emailList = new ArrayList<String>();
emailList.add("1@gmail.com");
emailList.add("2@gmail.com");
emailList.add("3@gmail.com");
emailList.add("4@gmail.com");

and i want to somehow print these strings one at a time using a loop where, the first time the loop iterates, it prints

1@gmail.com

second iteration

2@gmail.com

third iteration

3@gmail.com

fourth iteration

4@gmail.com

and so on

how would i do this?

I've tried using this method :

emailList.add("1@gmail.com");
emailList.add("2@gmail.com");
emailList.add("3@gmail.com");
emailList.add("4@gmail.com");
//for loop example
for (int i = 0; i < emailList.size(); i++) {
    System.out.println(emailList.get(i));
}

but all this does is print them all at once like this

1@gmail.com
2@gmail.com
3m@gmail.com
4@gmail.com
READ ALSO
My app worked the first time, then keeps crashing [duplicate]

My app worked the first time, then keeps crashing [duplicate]

This question already has an answer here:

62
Repeating 3 letters up to 6 times only

Repeating 3 letters up to 6 times only

I've been trying to use nested for loops to repeat the word, "hedgehog" with three letters up to 6 times only, however, it keeps going until it fully spells hedgehog

71
Spring Boot @Value is not being populated..why?

Spring Boot @Value is not being populated..why?

I am trying to get a value from my applicationproperties in Spring Boot using @Value but no matter what I do it is always null

36
Why do we need jackson databind?

Why do we need jackson databind?

I am new in JAVA EEMy question is, why do we need jackson databind? Because We can receive the Request Params by @ModelAttribute and requests through http PUT or POST by @RequestBody

72