bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String copyValueOf() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java String copyValueOf() 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.

___[] myStr1 = {'H', 'e', 'l', 'l', 'o'};
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The copyValueOf() method returns a String that represents the characters of a char array.
Definition and Usage
Java String copyValueOf() Method

❮ String Methods

Example

char[] myStr1 = {'H', 'e', 'l', 'l', 'o'};
String myStr2 = "";
myStr2 = myStr2.copyValueOf(myStr1, 0, 5);
System.out.println("Returned String: " + myStr2);

Definition and Usage

The copyValueOf() method returns a String that represents the characters of a char array.

This method returns a new String array and copies the characters into it.

Syntax

public static String copyValueOf(char[]
data , int
offset , int
count )

Parameter Values

ParameterDescription
dataA char array
offsetAn int value, representing the start index of the char array
countAn int value, representing the length of the char array

Technical Details

Returns:A String , representing the characters of the char array
Throws:StringIndexOutOfBoundsException - if offset is negative or out of reach, or if count is greater than the length of the char array, or negative

Previous

Java String contentEquals() Method

Next

Java String endsWith() Method