String a="aaa";
String b="bbb";
String c="ccc";
String d="ddd";
String p,q,r,s;
How can I assign values to p,q,r,s
randomly from a,b,c,d?
Like p should have value from a,b,c,d
and similarly for q,r,s
But the value should not repeat.
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.
The easiest way to do it is probably to just put all the strings in a array (or list, or similar), shuffle the list and assign the first value in the shuffled array to
p, the second toq, etc.Here’s an example of how to do this: