Day3 of #100DaysOfCode Challenge: Learn to Use java.util.List

This is my Day3 of #100DaysOfCode Challenge.

java.util.List is an Interface that accepts all Objects including non-literal types like Integer, Long, String, Character etc. For this #100daysOfCode challenge, I learned that:

  1. List store your data the same order how you add your items to the list.
  2. List also allows you to enter duplicate entries to the list.

below is my example code.

The above code will output:
1
5
3
6
4
2

A
C
AE
B
G
AE

The above code show’s how to iterate or make a loop through available items from the list using the for loop. There are two type of for loop operation that you can use to get the data, and the other example that most programmer call it classic for loop is like below example:

In addition to for loop, you can also use Iterator. Because List extends Iterator, we can use the following approach:

Hope you learned something from this post.

Leave a Reply

Your email address will not be published. Required fields are marked *