Sponsored By

Sign in to follow this  
naraku9333

Java Question

Recommended Posts

Hello,

I am trying to write a method that returns the index of a two dimensional array, I want to pass the array to the method and have it return the indices of a specific value. I am unclear if it is possible to return multple values (int's in my case) or if there is a better way. I know I can simply put the search algorithm in main, but Im trying to stick to a modular design (might as well get into the habit now). Any suggestions are well appreciated, thank you.

Share this post


Link to post
Share on other sites

There's no simple way to return multiple values. The easy solution would be to return an int[2] containing the indices.

Share this post


Link to post
Share on other sites
There's no simple way to return multiple values. The easy solution would be to return an int[2] containing the indices.

Ill look into that, what I initially wanted was to have the method ONLY search the array, pass the indices back to main to be passed to another method to change the value of the location. What I decided to do (at least for now) is pass the array to the method have it find and change the value and return the array, I dont know if this is an efficient way to do it but it works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this