Example lets say I have a data class:
data class MyList(
val username :String,
val correctQuestions :Int
)
Then an ArrayList like so:
var myList = ArrayList<MyList>()
myList is now populated with many values example:
myList.add(MyList("@Frank68", 54))
A user name might exist multiple times!
Now what is the most efficient way to create a new ArrayList
of type of MyList
which would show all the correct questions of each username? Of course each username should exist only one time in newly created ArrayList.
P.S.) I have updated my question to look more realistic even though this is a question constructed with minimum input to mind, in order to be easier to reproduce.