GradeAnalyser error class


#1

Hello, i’m stuck with this error :

GradeAnalyzer.java:3: error: class GradeAnalyser is public, should be declared in a file named GradeAnalyser.java
public class GradeAnalyser {
^
1 error

Here is my code :

import java.util.ArrayList;

public class GradeAnalyser {
  public GradeAnalyser () {}
  
  public int getAverage (ArrayList<Integer> grades) {
    if (grades.size() < 0) {
      System.out.println("Grades is empty.");
      return 0; // La mthode doit retourner un entier dans sa dfinition.
    } else {
      int sum = 0;
      for (Integer grade : grades) {
        sum = sum + grade;
      }
      int average = sum / grades.size();
      System.out.println(average);
      return average; // La encore, la mthode doit retourner un entier.
    }
  }
  
	public static void main(String[] args) {
  	ArrayList<Integer> myClassroom = new ArrayList<Integer>();
	  myClassroom.add(98);
  	myClassroom.add(92);
	  myClassroom.add(88);
  	myClassroom.add(75);
	  myClassroom.add(61);
  	myClassroom.add(89);
	  myClassroom.add(95);
  	GradeAnalyser myAnalyser = new GradeAnalyser();
	  myAnalyser.getAverage(myClassroom);
	}
}

First i watched the video but nothing relates to this problem. It doesn’t show any address action. I searched on google but i don’t understand how to specify an address here and why. The file name GradeAnalyser.java seems to be good at the top of the workspace. So why specify anything more?

Note that if i erase the public key word on lines 3 & 4, the error message change to this :

Error: Could not find or load main class GradeAnalyzer

Which seems to be another address problem.

Thank you for your time.


#2

the class name should match the filename.

GradeAnalyzer or GradeAnalyser, which should you use? (they are spelled differently (z vs s))


#3

■■■■! I didn’t see the “z”!

Thank you very much!