Sitelet https://howtodoinjava.com/tag/string-conversion/

String Conversion

Java String

Convert Float to String in Java with N Decimal Places

Convert a float to a String in Java with Float.toString() or String.valueOf(), and format it to 2 or N decimal places with String.format() or DecimalFormat. Learn the rounding rules, the locale trap and why 2.675f becomes 2.67.

Convert long to String in Java

Java example to convert long to String in two different ways using String.valueOf(long l) and Long.toString(long l) methods. Both are static methods.

Convert String to long in Java

Java examples of converting a String to a long type using Long.parseLong(String), Long.valueOf(String) and new Long(String) constructor.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.