Java Array : ArrayList

I have stored bundle of integer values into an ArrayList. However, there are a lot of same duplicate values stored into ArrayList. How can I compare each of every element so that I could only get the different values in ArrayList and store the different values to another ArrayList? As shown as below, I only need values of 36, 33, 31 & 29.

How if I have such output : 36,36,36,35,35,34,33,35,30…?
I need to store values of 36,35,34,33,35,30…into another ArrayList.

Output from my code:

Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 36
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 33
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 31
Battery Array Element : 29
Battery Array Element : 29
Battery Array Element : 29
Battery Array Element : 29
Battery Array Element : 29
Battery Array Element : 29
Battery Array Element : 29
Battery Array Element : 29


Source: java

Leave a Reply