butlertg
asked on
Converting int to String
I'm having trouble converting an integer array to a String. The current code is something like this:
import java.lang.*;
class Do_Stuff{
private int intPoints[];
public String Convert_To_String
{
String strOutput;
for (intCount = 0; intCount < 500;intCount++)
{
strOutput = strOutput + toString(intPoints[intCoun t]) + " "
}
}
}
When compiled, a warning that the wrong number of arguments are supplied to the toString function.
Any ideas?
butlertg
import java.lang.*;
class Do_Stuff{
private int intPoints[];
public String Convert_To_String
{
String strOutput;
for (intCount = 0; intCount < 500;intCount++)
{
strOutput = strOutput + toString(intPoints[intCoun
}
}
}
When compiled, a warning that the wrong number of arguments are supplied to the toString function.
Any ideas?
butlertg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is also a static method in Integer you can use:
public static String toString(int i);
so this line:
strOutput = strOutput + (new Integer(intCount[intcount] )).toStrin g()+ " ";
would become:
strOutput = strOutput + Integer.toString(intCount[ intcount]) +" ";
public static String toString(int i);
so this line:
strOutput = strOutput + (new Integer(intCount[intcount]
would become:
strOutput = strOutput + Integer.toString(intCount[
ASKER
Works great, but is a String the right type to use if I were to pass the output to a textbox on a web page?
butlertg
butlertg
Yeah
class Do_Stuff{
private int intPoints[];
public String Convert_To_String
{
String strOutput;
for (intCount = 0; intCount < 500;intCount++)
{
strOutput = strOutput + (new Integer(intCount) ).toString()+ " ";
}
}
}