The method valueOf() has several overloads that accept one parameter of different types and convert them to a String. Examples include boolean, char, char array, double, int and long. We can also convert a part of a char array to a String by passing:

  • offset – the index of the character to start converting from
  • count – the number of characters to convert

Available Signatures

public static String valueOf(boolean b)
public static String valueOf(char c)
public static String valueOf(char[] data)
public static String valueOf(char[] data, int offset, int count)
public static String valueOf(double d)
public static String valueOf(float f)
public static String valueOf(int i)
public static String valueOf(long l)
public static String valueOf(Object obj)


public void whenCallValueOf_thenCorrect() {
    long l = 200L;
    assertEquals("200", String.valueOf(l));
« Previous
Java String.trim()
November Discount Launch 2022 – Bottom
We’re finally running a Black Friday launch. All Courses are 30% off until the end of this week:


Generic footer banner
Comments are closed on this article!