Return Statements problem
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
adil_bashir
Junior Poster in Training
67 posts since Jan 2012
Reputation Points: 3
Solved Threads: 1
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
The problem is you're trying to ouput the entire integer array object hence the funky looking name.. try rather:
for(int i=0;i<ret.length;i++)
if(ret[i]!=0)//not show unintialized values of array
System.out.print(ret[i]+",");
This will output each value stored in the arrays index... output should be 49,50,51, ofcourse you can make it change to your needs.
So no the problem is not your return statement, its the way you are printing the array, you must iterate through each index, not print the objects name
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
adil_bashir
Junior Poster in Training
67 posts since Jan 2012
Reputation Points: 3
Solved Threads: 1
Thanks a lot dear..
Glad its fixed, Please could you mark this thread as solved if it is, so other members may know this and the Daniweb archive may grow Thanks.
BTW to mark as solved go to the bottom of this page and click the Mark this thread as solved.
DavidKroukamp
Practically a Master Poster
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169