If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Converting String to float

Print out the value of trans1 please. I have a feeling you have something in there that isn't valid. I ran the following program with the following results so I know that it isn't Java or the Float class:

Re: Converting String to float

Originally Posted by ProgramThis

Print out the value of trans1 please. I have a feeling you have something in there that isn't valid

I agree we need more info from the OP but if trans1 is not valid then trying to convert it to a float will result in a NumberFormatException being thrown. Of course, I suppose it's possible the OP is catching and ignoring exceptions and so doesn't even know an exception has been raised or does know and has just neglected to tell us.