Jo Jo Roid Jo Jo Roid - 1 year ago 65
Android Question

Android - Keep original List Array when distinct it ? Java

I need to have original list of data and changed list of data when I distinct it.

For exmaple :

List<Marketing_Points> userPointList = new ArrayList<>();
userPointList = /*Add a list of data */
Set<Marketing_Points> distinct = new HashSet<>();

I need to original list and changed list now but I have just changed list of data.What can I do for keep original list?

android studio
and in my
I am using :

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7

And my
is :

enter image description here

Answer Source

Simply create a dummy list and add all elements of original list to it and then you can use either of them to create a distinct list(though should use dummy list).

although Set doesn't allow duplicate value so if you have any duplicate value in list then it won't be added to Set(i guess u know this ) so keep a copy of original list to use later

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download