How do you shuffle elements in a Map, I am looking for something similar to the Collections.shuffle method.
How do you shuffle elements in a Map, I am looking for something similar
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A
Mapis not really ordered like aList, which means you cannot accessMapitems by index. Hence shuffling doesn’t make sense in general. But what you could do is this (I omitted generics for the example):