nextFloat() method undefined?

Started by
5 comments, last by LordShade 18 years, 4 months ago
Working with the J2ME Sun Emulator and am getting this error:
C:\DevTools\WTK22\apps\DarkWar\src\CDWPilot.java:43: cannot find symbol
symbol  : method nextFloat()
location: class java.util.Random
        float fRnd = rnd.nextFloat();
Here's the code basically:

Random rnd = new Random();
Date date = new Date();
long lTime = date.getTime();
        
rnd.setSeed(lTime);
float fRnd = rnd.nextFloat();
any clues? Thanx for the help.
Advertisement
Float numbers are not supported for J2ME.

Read here:
http://developers.sun.com/techtopics/mobility/midp/questions/float/
isn't it supported in the latter version of cldc? (i think 1.1?)

In latter versions (of CLDC) it is, as you can read in the link i posted.
But since MIDP 2.0 only requires CLDC 1.0 there probably won't be floating point support on most systems. And this may also be the reason for the error.
If you're using the Wireless Toolkit then you can set the CLDC version your project should use from the Project Settings dialog in the "API Selection" tab.

shmoove

latter nokia phones are cldc 1.1, i believe...i previously was compiling the .jar file as cldc 1.1 (unknowingly, i thought it was 1.0), and suddenly, it wouldn't install in one of the nokia test phones (forgot the model name, but it's series 60). :)

but it'd still be better to use one of the floating point libraries out there. i think. :)
The joy of learning a new platform. :) Read something but then get excitied about something else and forget about what you read before. hehe

Thanx for the heads up.

This topic is closed to new replies.

Advertisement