Java Error: Should be declared in a file named

前端 未结 6 1862
说谎
说谎 2020-12-31 23:21

I\'m fairly new to Java and trying to figure out how to solve the following error:

Error reads

CalculatorWithMemory.java:1: class Calculator is publi         


        
6条回答
  •  無奈伤痛
    2020-12-31 23:30

    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.

提交回复
热议问题