I'm fairly new to Java and trying to figure out how to solve the following error:
CalculatorWithMemory.java:1: class Calculator is public, should be declared
in a file named Calculator.java
public class Calculator
So my thought was that this means that I have to save 2 different .java files. However, this being for a class, I only have a provided text block to type my solution into so I cannot save these as .java files. Any thoughts on a solution would be great.
Thanks in advance!
To Provide all the information. I'm trying to solve for the following.
The superclass Calculator contains:
write a subclass, CalculatorWithMemory, that contains:
As the error message implies, if you declare a class as public
, it needs its own .java file. If you don't want to do that, then don't define it as public
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With