Skip to main content

int data to array data or string data

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2014-02-19
Points: 0

how it is possible [110310008]=[ 1,1,0,3,1,0,0,0,8] ; please help me.
i am just starting java to learn.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-05-05
Points: 0

Hi Badalahmmed,

I am not clear with your question, but i guess you have some integer number and the out put should be comma separated of each digit.

Sample code below,

public class NumberToString {

public static void main(String[] args) {
int num = 110310008;
String str = String.valueOf(num);
char[] ch = str.toCharArray();
StringBuilder sb = new StringBuilder();
sb.append("[ ");
for(int index=0; index sb.append(ch

sb.append(", ");
String res = sb.substring(0,sb.length()-2);
System.out.print(res+ " ]");