Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
boolean equals()
Tamara Lopez
Ranch Hand
Posts: 63
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If equals is a public method of Object, and every class inherits from Object, why does this compile in a class:
boolean equals(){return true}
without the public access modifier. Is that not against the rules of overriding?
Thank you
Joerg Waldmann
Greenhorn
Posts: 17
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Because the equals method at Object takes a parameter(Object o). So you don't override it, you overload it.
Tamara Lopez
Ranch Hand
Posts: 63
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sorry that's my fault, I typed it in wrong
I meant
boolean equals(Object o){returns true;}
This way it still doesn't result in a compiler error.
[ April 05, 2006: Message edited by: Tamara Lopez ]
Joerg Waldmann
Greenhorn
Posts: 17
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
That will result in a compiler error. Try it.
Joerg Waldmann
Greenhorn
Posts: 17
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In your second comment you wrote the access modifier public. Then it will compile, too. But with the default access it won't compile.
Tamara Lopez
Ranch Hand
Posts: 63
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Ok ignore me- sorry - i was typing it different than it was thinking it in my head
I've been selected to go to the moon! All thanks to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
instanceof
KB page no 526
equals() method
If == is true , does it mean equals(Object o) also true ?
util package
More...