Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how do I fix this error if I'm in java

0 votes
asked Mar 22, 2019 by Lucas (120 points)
"Main.java:7: error: class Money is public, should be declared in a file named Money.java"

2 Answers

0 votes
answered Mar 22, 2019 by FreddyH
I can't see what you are trying to do, but from the error message only:

In Java, all public classes should be in a file with the same name as the class. So class Foo should be in Foo.java and class Money should be in Money.java.
0 votes
answered Mar 25, 2019 by Minal Sharma
You need to rename the file in which you have define the class named Money as Money.java .
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...