Hi,
See instead of using Random class perse I would say use Math.random
which actually internally creates an instance of Random class & calls
nextDouble(). What Math.random() returns is a double value between 0.0 &
1.0. Now you will ask me what if I want to create random numbers between
0-25 then the answer is simple. First get Math.random() which will generate
between 0.0 & 1.0 & multiply it by the final limit which is 25
e.g
double d = Math.random();
int finalnum = (int)d *25;
& now you can just do this when ever you want.
Hope this solves your query.
Bye,
Jiger
>From: Poornima Visvesvaran <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Random class - out of topic
>Date: Sat, 7 Apr 2001 04:59:37 -0700
>
>Hello!
>
>Thanks for your help. Can you explain this briefly.
>
>Poornima Visvesvaran.
>
>--- Jiger Patel <[EMAIL PROTECTED]> wrote:
> > Comments below.
> > >From: Poornima Visvesvaran
> > <[EMAIL PROTECTED]>
> > >Reply-To: "A mailing list for discussion about Sun
> > Microsystem's Java
> > > Servlet API Technology."
> > <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: Random class - out of topic
> > >Date: Sat, 7 Apr 2001 03:27:25 -0700
> > >
> > >Hi friends,
> > >
> > >I want to generate int random numbers between 0 to
> > 25.
> > >
> > >Random r= new Random();
> > >int i=r.nextInt(25);
> > >
> > >
> > >now i should have values from 0 to 25 whenever we
> > run
> > >the process.
> > >
> > >Compilation is fine. At runtime, it is displaying
> > as
> > >there is no such method.
> > >
> > >All the other methods of random class
> > >(ie.nextInt(),nextDouble() etc) are working
> > >perfectly.)
> > >
> > >Can anyone help me.
> >
> > I would suggest instead to use Math.random() which
> > actually uses Random
> > class internally so we are saved from using getInt
> > or getDouble etc etc.
> > then cast it to the particular type.
> >
> > Hope this helps.
> > Bye,
> > Jiger
> > >
> > >With regards,
> > >
> > >Poornima Visvesvaran.
> > >
> > >__________________________________________________
> > >Do You Yahoo!?
> > >Get email at your own domain with Yahoo! Mail.
> > >http://personal.mail.yahoo.com/
> > >
> >
> >___________________________________________________________________________
> > >To unsubscribe, send email to [EMAIL PROTECTED]
> > and include in the body
> > >of the message "signoff SERVLET-INTEREST".
> > >
> > >Archives:
> >
>http://archives.java.sun.com/archives/servlet-interest.html
> > >Resources:
> >
>http://java.sun.com/products/servlet/external-resources.html
> > >LISTSERV Help:
> > http://www.lsoft.com/manuals/user/user.html
> >
> >
>_________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at
> > http://www.hotmail.com.
> >
> >
>___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED]
> > and include in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives:
> >
>http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
> >
>http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help:
>http://www.lsoft.com/manuals/user/user.html
>
>
>__________________________________________________
>Do You Yahoo!?
>Get email at your own domain with Yahoo! Mail.
>http://personal.mail.yahoo.com/
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html