Answer:
class WhatsIt
{
private static int [] values;
private double average;
public Double Average=average;
public WhatsIt () {values = new int [10]; findAvg(); }
public WhatsIt (int [] n) {values = n; findAvg(); }
public static void findAvg ()
{double sum = 0;
for (int i = 0; i < values.length; i++)
{sum += values[i]; }
average = 1.0 * sum / values.length;
System.out.println(Average);
System.out.println(average);
}
public static String ToString()
{
System.out.println(average); System.out.println(values.length);
return "Average: " + average + " Length: " + values.length;
}
public static void main(String[] args)
{
//WhatsIt();
//ToString();
findAvg();
}
}
The findAvg() calculates the average.
The reference to average is defined as below:
public double Average=average;
And when we call findAvg average is initialized, and Average is also initialized, which we can check through println statement.
Explanation:
Please check the answer section.