I\'m fairly new to Java and trying to figure out how to solve the following error:
CalculatorWithMemory.java:1: class Calculator is publi
This error occurs when the class name and the filename of a given Java program do not match. For example, say that the following program is saved in a file named Foo.java:
public class Bar {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
1 error found:
File: Foo.java [line: 1]
Error: class Bar is public, should be declared in a file named Bar.java
Since Foo does not match with Bar, the code doesn't compile. To fix this error, either rename the file or change the class name.