Header Ads

java -Convert String To Char Array

To convert a String to char array, uses String.toCharArray().

CODE : 

public class StringToCharArray {
    public static void main(String[] args) {
 
        String blogNname = "thanhcs94";
        char[] blogNameInCharArray = blogName.toCharArray();
 
        for(char temp: blogNameInCharArray){
            System.out.println(temp);
        }
    }
}


OUTPUT:


t
h
a
n
h
c
s
9
4






No comments:

Powered by Blogger.