int[] to String

How can i convert an Integer Array to String?
[80 byte] By [SumitPPa] at [2007-10-3 2:39:10]
# 1
Cross-posted http://forum.java.sun.com/thread.jspa?threadID=759952
CeciNEstPasUnProgrammeura at 2007-7-14 19:37:26 > top of Java-index,Java Essentials,New To Java...
# 2

There are several strategies but the easiest way to do it is make a char array the same size as your integer array. Then run through the int[] with a for loop and cast each int into a char;

chararray[i]=(char)intarray[i]

then just create a string based on the char array with

String s = new String(chararray);

never mind...do what the other guy said.

null

pornqueena at 2007-7-14 19:37:26 > top of Java-index,Java Essentials,New To Java...
# 3
Also you can do it that wayString strnum = new String();for(int i=0;i<intarray.length;i++){strnum= strnum.concat(String.valueOf(intarray));}>
JBNa at 2007-7-14 19:37:26 > top of Java-index,Java Essentials,New To Java...
# 4

> String strnum = new String();

- Use StringBuilder/StringBuffer for repeated concatenations.

> for(int i=0;i<intarray.length;i++)

> {

> strnum=

> strnum.concat(String.valueOf(intarray));

- Use code tags when posting code.

> }

- And using your code, the result will be:

12543265124654216532176521387235118765

Probably not as useful as it looks.

- And: Arrays.toString(theArray) already does what you're trying to do, in Java 1.5.0.

CeciNEstPasUnProgrammeura at 2007-7-14 19:37:26 > top of Java-index,Java Essentials,New To Java...