bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String valueOf() Method

❮ String Methods

Example

char[] myArray = {'a', 'b', 'c'};
System.out.println(String.valueOf(myArray));
System.out.println(String.valueOf('A'));
System.out.println(String.valueOf(true));
System.out.println(String.valueOf(4.5f));
System.out.println(String.valueOf(5.2));
System.out.println(String.valueOf(12));
System.out.println(String.valueOf(1400L));

Definition and Usage

The valueOf() method returns the string representation of the specified value.

One of the following

public static String valueOf(boolean
data )
public static String valueOf(char
data )
public static String valueOf(char[]
data )
public static String valueOf(char[]
data , int
start , int
length )
public static String valueOf(double
data )
public static String valueOf(float
data )
public static String valueOf(int
data )
public static String valueOf(long
data )
public static String valueOf(Object
data )

Parameter Values

ParameterDescription
dataRequired. The data to be represented as a string.
startOptional. If a char array is provided, a subset of the array can be represented. This argument specifies where the subset starts.
lengthOptional. If a char array is provided, a subset of the array can be represented. This argument specifies the length of the subset.

Technical Details

Returns:A String representation of the argument.
Throws:IndexOutOfBoundsException - If start or length are negative or start + length is greater than the length of the array.
Java version:Any

Previous

Java String trim() Method

Next

Java Math Methods