Convert float to String in Java

With the help of String.valueOf() and Float.toString() methods, you can convert float to String in Java.

Example of Java float to String conversion

Following is the example that will show conversion from float to String-

public class Example
	public static void main(String args[])
		float i = 10.5F;
		String a = String.valueOf(i);		
		String b = Float.toString(i);
		System.out.println("a = "+a);
		System.out.println("b = "+b);


a = 10.5
b = 10.5