i need to return the ASCII value of the argument passed in the StringtoIntfunc(). But i am not getting the real ASCII values and i think the problem is with the return statements? please help.
public class StringIntfc
{
public int[] StringtoIntfunc(String s)
{
int j =0;
int k[] = new int[20];
for(int i=0;i<s.length();++i)
{
char c = s.charAt( i );
j = (int) c;
k = j;
}
return k;
}
}
public class StringIntTest
{
public static void main(String[] ar)
{
int ret[] = new int[4];
StringIntfc a = new StringIntfc();
ret = a.StringtoIntfunc("123");
System.out.println("return value is:" + ret);
}
}
The output of this program is: [I@19821f
But the actual output should be 495051