I have an arraylist <> of objects. It have 4 -5 objects at most. I want to get 3 distinctive unique object into another

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

I have an arraylist <> of objects. It have 4 -5 objects at most. I want to get 3 distinctive unique object into another

Post by answerhappygod »

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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply