Discussion Board
Go to the previous messageThere are no next messages
Current Forum: Homework 1 Forum
Date: Sat Sep 8 2001 10:44 am
Author: Scherer, Sebastian <sebastian.scherer@cs.cmu.edu>
Subject: Re: float to Float

Hi!
Maybe you confused the static method toString(float x) with the dynamic object method toString() .(That is the danger of overloading functions.)
You can use the static methods of Float just as you can use any library.
You don't have initialize anything, but when you want to use an object you have to create an instance of it by calling its instructor. After that in a object variable your whole object is stored and you access its values through the object methods like toString() for example.
Two ways to convert a float value to a String:

float t = 12;
String x = new String(Float.toString(t));

The second way by creating a float object:

Float o = new Float(12);
String x = new String(o.toString());

I hope this helps

Sebastian


Post response

Go to the previous messageThere are no next messages
Current Thread Detail:
float to Float      Shi, Ying      Fri Sep 7 2001 6:56 pm       
Re: float to Float      Scherer, Sebastian      Sat Sep 8 2001 10:44 am       

Back to previous screen