this is actually a fairly short version. you could use a float and 0.10f, or a short if you want, to make it use negligibly less memory. but this sort of thing is probably the best solution. make a big bowl of copypasta, man

using one of these wouldn't actually make it any shorter, just slightly more efficient. Anyone else have a better way?
edit: derpy moment, just make a method for the percentage. why didn't i think of that before? drugs.
private Random ran = new Random(); #generate random object
public boolean percentmethod (int desiredchance) {
int x = ran.nextInt(101) #sets x to a random integer between 0 & 100(doesn't reach max)
if (a==1) {
if (x<=desiredchance) {
return true;
}
}
execute whatever you want in your main program, using the result to decide by calling percentmethod(20) for a 20% chance of returning true. etc. does that help?
Last edited by rcarey; Sep 27, 2012 at 10:05 PM.