Regarding getting random values

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

Regarding getting random values

Postby uvrpavan » Fri May 18, 2007 4:13 am

how to use random values less than a particular value?
and how to avoid negative values?
uvrpavan
 
Posts: 19
Joined: Sun Feb 11, 2007 8:52 am

Postby DevelopmentTeam » Fri May 18, 2007 5:33 am

This function will return number between 0 to n

Code: Select all
    private int Rand(int n) {
            return Math.abs(rnd.nextInt()%n);
    }
User avatar
DevelopmentTeam
Site Admin
 
Posts: 661
Joined: Tue Aug 15, 2006 8:39 am
Location: India


Return to J2ME Games

Who is online

Users browsing this forum: No registered users and 3 guests

cron