in my class SummerStats I need to create another method that locates the largest element of the array created in my method setSalaries. How can I call the array, "salaries" to another method in the same class?
class SummerStats
{
public SummerStats()
{
}
public int[][] setSalaries(int people, int years)
{
int[][] salaries = new int[people][years];
//rows respresent people and columns represent years
for (people = 0; people < salaries.length; people++)
{
for (years = 0; years < salaries[people].length; years++)
{
salaries[people][years] = (int)(1000 + Math.random()*1000);
}
}
return salaries;
}
Also, my test class is
import java.util.*;
public class testSummerStats
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
SummerStats one = new SummerStats();
System.out.println("Enter people, then years: ");
int x = input.nextInt();
int y = input.nextInt();
one.setSalaries(x, y);
}
}
SummerStatsclass.