java tutorial - Java Strings toCharArray() method - java programming - learn java - java basics - java for beginners



Java strings to char array

Learn Java - Java tutorial - Java strings tochararray() - Java examples - Java programs

Description

The toCharArray () method — in Java converts this string to a new array of characters.

Syntax

Syntax method:

public char[] toCharArray()
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • no.

Return value

  • In Java, toCharArray () returns a newly allocated character array whose length is equal to the length of the given string and the contents that are initialized contain a sequence of characters represented by this string.

Sample Code

import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to wikitechy.com");

      System.out.print("Return Value :" );
      System.out.println(Str.toCharArray() );
   }
}

click below button to copy the code. By - java tutorial - team

Output

Return Value :Welcome to wikitechy.com

Related Searches to Java Strings toCharArray() method