Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java String valueOf() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___[] myArray = {'a', 'b', 'c'};3Order
Put the learning moves in the order that makes the concept easiest to apply.
The valueOf() method returns the string representation of the specified value.
Definition and Usage
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
| 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 |