Java String getChars()

The java string getChars() method copies the content of this string into specified char array. There are 4 arguments passed in getChars() method. The signature of getChars() method is given below:


Internal implementation


Signature

The signature or syntax of string getChars() method is given below:


Returns

It doesn't return any value.


Throws

It throws StringIndexOutOfBoundsException if beginIndex is greater than endIndex.


Java String getChars() method example

Test it Now

Output:

w3cschoool

Java String getChars() Method Example 2

It throws an exception if index value exceeds array range. Let's see an example.

Output:

java.lang.StringIndexOutOfBoundsException: offset 10, count 14, length 20




Contact US

Email:[email protected]

String getChars()
10/30