• Post Reply Bookmark Topic Watch Topic
  • New Topic

Return Statements problem  RSS feed

 
adi bashir
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adi, please CarefullyChooseOneForum and UseOneThreadPerQuestion. The other thread you started in Java in General has been locked.
 
adi bashir
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt got the response and so i posted it double. sorry but please help me out
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're printing the return value, which is an array. What you see is the String returned from the array's toString() which is inherited form Object.

If you want to print the contents of the array, you have to either iterate over the array or use the appropriate method of the java.util.Arrays utility class.
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.you are uusing int[] return type from your function but in return statement you return only single value...change your return statement.

2. your method is wrong way, use Array class for better solution.
 
adi bashir
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which return statement to use? can you please elaborate a little more?
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in function you declare int[20] and below code when you save return values in other int array, it is declare only int[4], first change this thing, after that you must be iterate all value in the array when you want to print all ascci values in main method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!