Tochararray java

Hey guys!! Welcome to flower brackets blog. Today we will delve into tochararray java.

tochararray java

Tochararray java

Also Read – Char Array to String Java Program


This method basically converts a string into a character array. To translate string to character array tochararray() method is used in java.


public char[] toCharArray()


tochararray method returns new character array with its length same as given string.

Let’s see an example,

Example :

public class StringCharArray
   public static void main(String[] args)
      String strOriginal = "Flower Brackets";
      char arr[];
      // using toCharArray() method
      arr = strOriginal.toCharArray();
      for(int x = 0; x < arr.length; x++)


Flower Brackets

Related Posts