IntelliJ Java IDE
The moose likes Beginning Java and the fly likes Return Statements problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Return Statements problem" Watch "Return Statements problem" New topic
Author

Return Statements problem

adi bashir
Greenhorn

Joined: Feb 06, 2012
Posts: 9
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

Joined: May 03, 2008
Posts: 3218

adi, please CarefullyChooseOneForum and UseOneThreadPerQuestion. The other thread you started in Java in General has been locked.


luck, db
There are no new questions, but there may be new answers.
adi bashir
Greenhorn

Joined: Feb 06, 2012
Posts: 9
i didnt got the response and so i posted it double. sorry but please help me out
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 3218

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

Joined: Jun 15, 2010
Posts: 205

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.


SCJP 6- 91%, IBM DB2, IBM RAD Certified
adi bashir
Greenhorn

Joined: Feb 06, 2012
Posts: 9
which return statement to use? can you please elaborate a little more?
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 205

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.
 
 
subject: Return Statements problem
 
Threads others viewed
Sorting an array?
Initilization.
how to swap two integers inside a function ?
Array Indexing
Returning multiple objects
developer file tools