error in typecasting

dear forum member(s),

Pleasr help me tackle this exception.

I have an array of string, to which iam adding dynamically strings or integers or long or float or even boolean values.

I have to typecast those values to int or long or etc..according to their original type.I am using the following code but am getting

NumberFormatException.

Class types=method.getParameterTypes

for(int i=0;i<numberOfParameters;i++)

{

String values=parameterList[i];// array

if (types[i].equals(int.class) || types[i].equals(Integer.class))

parameters[i] =new Integer(values);

elseif (types[i].equals(long.class) || types[i].equals(Long.class))

parameters[i] =new Long(values);

elseif (types[i].equals(String.class))

parameters[i] = values;

elseif (types[i].equals(float.class) || types[i].equals(Float.class))

parameters[i] =new Float(values);

elseif (types[i].equals(boolean.class) || types[i].equals(Boolean.class))

parameters[i] =new Boolean(values);

elseif

System.out.println("do not support data type");

}

Regards.>

[1829 byte] By [divyabhaskarana] at [2007-10-3 2:26:58]
# 1
Instead of type String use type Object for the parameterList array. None of the wrapper classes is a subclass of String. You can only assign values to a variable, if the type of the value equals the type of the variable or is a subclass of the variable type.
falke2203a at 2007-7-14 19:26:02 > top of Java-index,Java Essentials,New To Java...
# 2
thank you ,its working fine now...divya
divyabhaskarana at 2007-7-14 19:26:02 > top of Java-index,Java Essentials,New To Java...