Code:
public class ArrayMethods
{
private double[] a;
public static double sumOfArrays(double[] a)
{
double max = a[0];
for(int i =1; i<a.length; i++)
{
if(a[i] > max)
max = a[i];
}
double min = a[1];
for(int i =1; i<a.length; i++)
{
if(a[i] < min)
min = a[i];
}
double difference = max - min;
return difference;
}
public static void main(String[] args)
{
double [] b = {43.9,12.3,99.6,48.2,2.1,65.5};
double diff = differenceOfArrays(b);
System.out.println(diff);
}
}
When I run the code, at the line where I run the method I wrote,
double diff = differenceOfArrays(b);, it says it cannot find the symbol. Before I wrote it, I didn't have the method as static and when I didn't have static there it said that it couldn't be dereferenced. So I made it static. Could anyone help with this? It would be greatly appreciated.