Open In App

CharArrayWriter toCharArray() method in Java with examples

Last Updated : 14 Feb, 2022
Summarize
Comments
Improve
Suggest changes
Share
2 Likes
Like
Report

The toCharArray() method of the CharArrayWriter class in Java returns a copy of the input data.
Syntax
 

public char[] toCharArray()


Parameters: This method does not accept any parameter.
Return Value: This method returns a copy of the input data. 
Below program illustrate the above method: 
Program 1: 
 


Output: 
toCharArray : G
toCharArray : E
toCharArray : E
toCharArray : K
toCharArray : S

 

Program 2: 
 


Output: 
toCharArray : G
toCharArray : O
toCharArray : P
toCharArray : A
toCharArray : L
toCharArray : D
toCharArray : A
toCharArray : V
toCharArray : E

 

Reference: https://docs.oracle.com/javase/10/docs/api/java/io/CharArrayWriter.html#toCharArray()
 


Similar Reads