bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String getChars() Method

Flash cards

Review the key moves

1/4
Core idea

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

2Order

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

The getChars() method copies characters from a string to a char array.
Definition and Usage
Java String getChars() Method

❮ String Methods

char

Definition and Usage

The getChars() method copies characters from a string to a char array.

Syntax

public void getChars(int
start , int
end , char[]
destination , int
position )

Parameter Values

ParameterDescription
startRequired. The position in the string of the first character to be copied.
endRequired. The position in the string after the last character to be copied.
destinationRequired. The array to which the characters are copied.
positionRequired. The position in the destination array to which the copied characters are written.

Technical Details

Returns:None
Throws:IndexOutOfBoundsException - In any of these conditions: If start or position are negative If end is greater than the length of the string If start is greater than end If the copied characters cannot fit in the destination array
Java version:Any
  • If start or position are negative
  • If end is greater than the length of the string
  • If start is greater than end
  • If the copied characters cannot fit in the destination array

Previous

Java String getBytes() Method

Next

Java String hashCode() Method