I have an arraylist <> of objects. It have 4 -5 objects at most. I want to get 3 distinctive unique object into another
Posted: Fri Apr 29, 2022 7:15 am
I have an arraylist <> of objects. It have 4 -5 objects at
most. I want to get 3 distinctive unique object into
another arraylist. without creating new method or use
return
the selection of those 3 objects must be random too (for
example arraylist A have a b c d e, I want to get 3 items to
Array list B, then B members will always be 3 but changed
each
time i run code randomly (abc, acd, ade, bed)
- ArrayList<>
- java
- can't create new method
- can't use return
- get 3 random unique object of Arraylist A to Arraylist
B
- Object have same interface but different
class
- Please provide example code
most. I want to get 3 distinctive unique object into
another arraylist. without creating new method or use
return
the selection of those 3 objects must be random too (for
example arraylist A have a b c d e, I want to get 3 items to
Array list B, then B members will always be 3 but changed
each
time i run code randomly (abc, acd, ade, bed)
- ArrayList<>
- java
- can't create new method
- can't use return
- get 3 random unique object of Arraylist A to Arraylist
B
- Object have same interface but different
class
- Please provide example code