This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes Using Floating Point Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Using Floating Point " Watch "Using Floating Point " New topic
Author

Using Floating Point

Matt Dooley
Greenhorn

Joined: Nov 16, 2008
Posts: 1
I am new to J2ME and am trying to do a simple app for a blackberry. I am trying to read a user's input using a BasicEditField and then convert this to a float do some math and convert the float answer to a string and write back out again.

java:171: valueOf(java.lang.String) in java.lang.Float cannot be applied to (net.rim.device.api.ui.component.BasicEditField)
float cf = Float.valueOf(capf)

If I try to convert to a string first, I get the following error:
java:169: toString() in java.lang.Object cannot be applied to (net.rim.device.api.ui.component.BasicEditField)
String sx = toString(size);

Any suggestions on how to read input, do the math and write output?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17038
    
  26

You're going to have to get the VALUE stored in the BasicEditField. BasicEditField isn't a String, it's a UI control class.


An IDE is no substitute for an Intelligent Developer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Floating Point
 
jQuery in Action, 3rd edition