title: Locate the largest element in a multidimensional arrays
body: <p>I have to write a program using a method that returns the location of the largest element in a two dimensional array.</p>
  
  <p>example</p>
  
  <p>Enter the number of rows and columns of the array: </p>
  
  <p>3 4</p>
  
  <p>Enter the array: </p>
  
  <p>23.5 35 2 10</p>
  
  <p>4.5 3 45 3.5</p>
  
  <p>35 44 5.5 9.6</p>
  
  <p>the location of the largest element is at (1, 2)</p>
  
  <p>I have finished my code but it isn't working. How can I fix it? All I got are the following errors:</p>
  
  <p>symbol  : variable maxvalue</p>
  
  <p>location: class int[]</p>
  
  <pre><code>                    if (a[i][j] &gt; largest.maxvalue)
                                           ^
  </code></pre>
  
  <p>homework1a.java:51: row is already defined in locateLargest(double[][])</p>
  
  <pre><code>                            double row = i;
                                     ^
  </code></pre>
  
  <p>homework1a.java:52: column is already defined in locateLargest(double[][])</p>
  
  <pre><code>                            double column = j;
                                     ^
  </code></pre>
  
  <p>homework1a.java:53: maxValue is already defined in locateLargest(double[][])</p>
  
  <pre><code>                            double maxValue = a[i][j];
                                     ^
  </code></pre>
  
  <p>homework1a.java:88: i is already defined in main(java.lang.String[])</p>
  
  <pre><code>                    for (int i = 0; i &lt; 2; i++)
                               ^
  </code></pre>
  
  <p>5 errors</p>
  
  <p>My code</p>
  
  <pre><code>import java.util.Scanner;
  public class hwm1 {
  
  public static int[] locateLargest(double[][] a)
  {
  
          int[] largest = new int[2];
  
          double row = 0;
          double column = 0;
          double maxValue = a[0][0];
  
          for (int i = 0; i &lt; a.length; i++)
          {
                  for (int j = 0; j &lt; a.length; j++)
                  {
                          if (a[i][j] &gt; largest.maxvalue)
                          {
                                  double row = i;
                                  double column = j;
                                  double maxValue = a[i][j];
                          }
                  }
          }
  
          return largest;
  }
  public static void main(String[] args)
   {
                  //Create Scanner
                  Scanner input = new Scanner(System.in);
  
                  //User input rows and columns
                  System.out.println("Enter the number of rows and columns in the array: ");
  
                  int numberOfRows = input.nextInt();
                  int numberOfColumns = input.nextInt();
  
  
                  //User input data in array
                  System.out.println("Enter numbers into array: ");
                  //Create array
                  double[][] a = new double[numberOfRows][numberOfColumns];
                  for (int i = 0; i &lt; a.length; i++)
        {
                          for (int j = 0; j &lt; a[i].length; j++)
             {
                                  a[i][j] = input.nextDouble();
             }
                          int[] largest = locateLargest(a);
                          System.out.println("The location of the largest element is at "+ "("+largest[0] +", " + largest[1] + ")");
                          for (int i = 0; i &lt; 2; i++)
                  {
                          System.out.print(largest[i]);
             }
        }
   }
  </code></pre>
  
  <p>}</p>