Skip to Content

Convert Java Float Object to String Object Example

  1. /*
  2.   Convert Float object to String object
  3.   This example shows how a Float object can be converted into a String object.
  4. */
  5.  
  6. public class JavaFloatToStringExample {
  7.  
  8.   public static void main(String[] args) {
  9.  
  10.     Float fObj = new Float(10.25);
  11.     //use toString method of Float class to convert Float into String.
  12.     String str = fObj.toString();
  13.     System.out.println("Float converted to String as " + str);
  14.   }
  15. }
  16.  
  17. /*
  18. Output of the program would be
  19. Float converted to String as 10.25
  20. */