Tuesday, July 9, 2013

[android help] How to generate random number with out duplicates using JSON array in android


How to generate random number with out duplicates using JSON array in android


How to generate random number with out duplicates using JSON array in android - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I am new to android. I am doing quize app.I have one JSON array text file.how to generate random number with out repetation using JSON array in android..please help me Thank you adv.. this is my sample code



public static JSONArray getQuesList()throws JSONException{

Random rnd = new Random();

for (int i = quesList.length() - 1; i >= 0; i--)
{
int j = rnd.nextInt(i + 1);
// Simple swap
Object object = quesList.get(j);
quesList.put(j, quesList.get(i));
quesList.put(i, object);
}
return quesList;


}















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...