Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
The equals method is fine.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Originally posted by Jean-Francois Briere:
> I don't think the point of the method was to override the equals method in Object class.
How can you say that from the code snippet shown by the OP?
I've seen many java beginners who have made the same mistake while their intention was to override Object equals().
But then what would be the point?
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Originally posted by Ernest Friedman-Hill:
After this lovely, long, and ultimately pointless discussion, perhaps we could return to the OP's error? When s/he "starts the program", it says something about "NoSuchMethodError." This is precisely what you see if you try to launch a class from the command line that doesn't have a main() routine -- and his class does not have one.
msjei, please ignore the previous posts; you could come back to them when you've learned some more Java. Right now, all you need to know is that when you start a class by running, say,
java Name1
Java looks for a method that looks like
public static void main(String[]) {
// SOMETHING
}
Where the "// SOMETHING" is replaced by code that does whatever you want your program to do when you run it. There's nothing wrong with the class you've written, really; it's just that it doesn 't have a "main" routine, so Java doesn't know how to run it. Add a "main" method, and in that method, write some code to use Name1 objects to do something. Create one, call input(), call output(), etc.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Originally posted by Garrett Rowe:
Just like I said in my first reply. :roll:
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|