How to convert Java String to Char array

Use String.toCharArray() method to convert string to array of charactors.

Example

package com.pretech;
public class StringToCharArray {
	public static void main(String[] args) {
		char[] mycharArray = "Welcome to my blog".toCharArray();
		System.out.println(mycharArray);
		
	}
}

No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts