toCharArray() Java - Convert a string to an array of characters

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

toCharArray() in Java

The toCharArray() method converts a string to an array of char elements.

Syntax

How to Call the Method:

Example:

If you run this code on your computer, you will see the following in the console:

Commentary:

There is a string "ABC". With the help of the toCharArray() method, we have turned the string into an array of char elements {'A', 'B', 'C'}.

To show how it works, we used the loop and then displayed every char element in the console.

That's it for this article. You can find more articles in our Java Tutorial for Beginners.

 

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr
Самоучители--узнать детальнее--