int to char array in Java

There are many ways to convert a primitive integer to array in Java.

Cast as String

int i = 1234;
char[] chars = ("" + i).toCharArray();

String class

char[] chars = String.valueOf(1234).toCharArray();


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>