Some_other_guy Some_other_guy - 1 year ago 80
Java Question

Convert an integer to an array of characters : java

What is the best way to convert an integer into a character array?

Input: 1234

Output: {1,2,3,4}

Keeping in mind the vastness of Java language what will be the best and most efficient way of doing it?

Answer Source
int i = 1234;
char[] chars = ("" + i).toCharArray();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download