Link to home
Start Free TrialLog in
Avatar of butlertg
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[intCount]) + " "
}
}
}

When compiled, a warning that the wrong number of arguments are supplied to the toString function.

Any ideas?
butlertg
Avatar of sameerjoshi
sameerjoshi

just say



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()+ " ";
               }
         }
    }
ASKER CERTIFIED SOLUTION
Avatar of sameerjoshi
sameerjoshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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])).toString()+ " ";


would become:


    strOutput = strOutput + Integer.toString(intCount[intcount])+" ";
Avatar of butlertg

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