Number to a String


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Number to a String

  1. #1
    Join Date
    Jan 2003
    Posts
    4

    Question Number to a String

    Hi, thank you in advance to anyone who can help me out...i need to change a "double" into a "String"...
    i tried to use the myString = myDouble.toString(), but it said that i couldn't dereference double...i need to turn the double into a String because i am placing the value into a setText() method...if i try to put the double in as an argument it says it is not allowed...i assume i need to put in a String argument, setText(String)...any info will be much appreciated....

    also, i was curious if there is a "forward space" command just like the "back space" command...i know the back space is "\b" but i wanted to delete text from the front of a string using the forward space command...

    Thank you all

  2. #2
    Join Date
    Oct 2002
    Posts
    66
    A double is a primitive but the method you are using works only on an object. You'd either have to make the double as an object - Double myDouble = new Double(yourDouble) - first, or you can get the String straight from it by using the static method - myString = Double.toString(yourDouble).

    Not sure about the forward space thing. I know you can use trim() to remove unwanted white space, if that's what you need or you could make a substring specificying the start and end, but just miss out the character you don't need. Otherwise, look at using StringBuffer as that has slightly more complicated functions.

    Hope that helps.
    Meethoss

  3. #3
    Join Date
    Jan 2003
    Posts
    4

    Wink Thanx

    Thanks a lot Meethoss, ur advice helped me out 100%...i'm no longer stuck...i'm sure i'll have some more questions...c-ya

  4. #4
    Join Date
    Oct 2002
    Posts
    66
    No problem! It's a pleasure to be of service
    Meethoss

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center