I need help with my program. Beginning java student here.
I am supposed to create an array by prompting the user for the number of rows and columns.
Then the user is to enter the rows and columns.
At this point, a method is invoked that is to locate the largest element and then return the position of the element in the array.
As far as I can tell, my main method is correct, but I'm having trouble with the other method.
We are to create an array that stores the location of the current largest element.
Could anyone offer any help? After much trial and error, this is the version that shows no red flags in Eclipse, but it's result is this as the location of the largest element "[I@14318bb". I have a feeling this is wrong LOL.
This is the pseudocode we are to follow from my instructor:
// import package for reading keyboard input
// program name
public class LargestElementLocator
// program start
public static void main (String  args)
// prompt user for number of rows and columns
// create an empty array based on user input
// for each row
// promt user for row elements
// store elements in appropriate row
// end for
// invoke locateLargest method and store its return values
// display the row an columns of the largest element
// in array based on the values returend by method
// locateLargest method
public static int  locateLargest(double  a)
// initialize variable largest to 0
// create array b of size 2 to store row and colum of
// largest element in a
// for each row of array a
// for each column of array a
// if element in array a is larger than largest
// store row and column of array a in array b
// end if
// end for
// end for
// return array b
My apologies for the long post.
Thank you for any advice in advance.
You cannot print a primitive array as such using System.out.println().
If you do so, it will return '[' indicating it is an array of 'I' - int type followed by '@' and the hashcode value of the array
Try this, this might help
Thanks for your reply.
Our instructor said we have to code using just the concepts we've covered so far.
We haven't got that far in the class. I have to evidently keep it more simple than that.
I think I might start from scratch and try to go a simpler route.
You might see me on this board later today! lol