The Artima Developer Community
Sponsored Link

Java Answers Forum
Converting a float to object

1 reply on 1 page. Most recent reply: Apr 17, 2003 6:50 PM by Singh M.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Courtenay

Posts: 23
Nickname: courtz
Registered: Apr, 2003

Converting a float to object Posted: Apr 17, 2003 3:05 PM
Reply to this message Reply
Advertisement
Ok so I know a float is an object. My problem is that I have a method which im using from another class which only writes objects to a file which im using. In my particular program, I add two floats and then I need to write the answer out to the file using a method
writeObject(Object args)
. How do I get round this supposedly easy problem?


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: Converting a float to object Posted: Apr 17, 2003 6:50 PM
Reply to this message Reply
> Ok so I know a float is an object. My problem is that I
> have a method which im using from another class which only
> writes objects to a file which im using. In my particular
> program, I add two floats and then I need to write the
> answer out to the file using a method
>
writeObject(Object args)
. How do I get round
> this supposedly easy problem?

float is not an object, Float is.

convert your float into Float as follows...

Float obj = new Float(f); // where f is of type float.

and pass obj to the concerned method.

or

pass them to writeObject as follows...

writeObject(String.valueOf(f));

Flat View: This topic has 1 reply on 1 page
Topic: Count Character Occurrence Previous Topic   Next Topic Topic: NEED help with a simple program

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use