❮ 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
| Parameter | Description |
|---|---|
| data | Required. The data to be represented as a string. |
| start | Optional. If a char array is provided, a subset of the array can be represented. This argument specifies where the subset starts. |
| length | Optional. 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 |