Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

bug in j2me implementation of Random?

Thread view: 
kloro - 26 Sep 2006 23:33 GMT
bug in j2me Random implementation?
From:
tom arnall <kloro2006@gmail.com>
 To:
Date:
Sunday 05:17:49 pm
the following:

       public class Test1 extends MIDlet implements CommandListener {

               public void startApp() {
                       Random rand = new Random();
                       System.out.println(rand.nextInt(5));
               }
       .
       .
       .

from the J2me compiler gets:

       home/kloro/cell/WTK2.2/apps/Test1/src/Test1.java:11: nextInt()
in
               java.util.Random cannot be applied to (int)
       System.out.println(rand.nextInt(5));

yet the doc' for Random states in the methods section:

       nextInt(int n) - Returns a pseudorandom, uniformly distributed
int value
       between 0 (inclusive) and the specified value (exclusive),
drawn from this
       random number generator's sequence.
                       
same type of result for long, double, short.
Patricia Shanahan - 26 Sep 2006 23:39 GMT
> bug in j2me Random implementation?
> From:
[quoted text clipped - 30 lines]
>                          
> same type of result for long, double, short.

Which documentation are you using for the J2ME API?

Patricia
tom arnll - 28 Sep 2006 17:44 GMT
>> bug in j2me Random implementation?
>> From:
[quoted text clipped - 34 lines]
>
> Patricia

egg on face! i tried it again this a.m. and it works. have no idea of what i
changed to make things different. thanks for your posts.

tom arnall

Signature

Posted via a free Usenet account from http://www.teranews.com

Daniel Dyer - 26 Sep 2006 23:56 GMT
> bug in j2me Random implementation?
> From:
[quoted text clipped - 20 lines]
>                 java.util.Random cannot be applied to (int)
>         System.out.println(rand.nextInt(5));

That method doesn't exist in the J2ME version.  The J2ME java.* classes  
correspond to JDK 1.1 classes.  The nextInt(int) method was introduced in  
J2SE 1.2.

If you need this method, you can extend the Random class and add this  
method (just cut and paste it from the source of the Java SE version of  
java.util.Random).

> yet the doc' for Random states in the methods section:
>
[quoted text clipped - 4 lines]
>         random number generator's sequence.
> same type of result for long, double, short.

You're reading the wrong version of the documentation, you need the J2ME  
docs.

Dan.

Signature

Daniel Dyer
http://www.uncommons.org

kloro - 27 Sep 2006 18:31 GMT
> > bug in j2me Random implementation?
> > From:
[quoted text clipped - 40 lines]
> You're reading the wrong version of the documentation, you need the J2ME
> docs.

following is the url of the doc' section from which i quoted, as set up
by the WTK2.2 installer:

file:///home/kloro/cell/WTK2.2/docs/api/midp/java/util/Random.html#next(int)
kloro - 27 Sep 2006 21:27 GMT
> > > bug in j2me Random implementation?
> > > From:
[quoted text clipped - 45 lines]
>
> file:///home/kloro/cell/WTK2.2/docs/api/midp/java/util/Random.html#next(int)

sorry, make that url:

file:///home/kloro/cell/WTK2.2/docs/api/midp/java/util/Random.html#nextInt(int)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.