This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setText

 
Candy Bortniker
Ranch Hand
Posts: 123
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a value that has to be defined as a float. I'm trying to right this value to a text field using setText but everything that I have tried gives me a compile error. How do I handle this?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setText() wants a String as an argument, so you need to convert your float to a String. There are (as is often the case) several ways to do this, but easy one is the static method String.valueOf(); there's an overloaded version of this for just about every primitive type. So you could say
 
Ransika deSilva
Ranch Hand
Posts: 524
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
There is another way of type casting a Float value to a String value.
float x = 0.0f;
String text = Float.toString(x);
Hope it is worth to you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic