How To Convert String To Char Array In Java?

This tutorial is simple example for converting a string object into a simple character array. Lets look at the example.

package javabeat.net.core;

public class StringToCharArrayExample {
	public static void main(String[] args) {

		String str = "javabeat";
		char[] strInCharArray = str.toCharArray();

		for (char charVal : strInCharArray) {
			System.out.println(charVal);
		}
	}
}

Output…

j
a
v
a
b
e
a
t

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Pin It on Pinterest

Share This

Share this post with your friends!

Share This

Share this post with your friends!