For instance, I know Objective-C class methods could be overridden and Java’s not.
What’s the benefit of this and what other diferences are there?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In a nutshell, static methods in Java are just functions that are attached to a class. They don’t work like instance methods in that you can’t use this or super. They effectively have no real concept of them being in a class.
Objective-C class methods are very different though. They are exactly the same as instance methods, except on a class. This isn’t too surprising given that classes are objects in Obj-C. As such they go through all the same dynamic dispatch, you can use self to access other class methods, you can use super to call into the superclass’s class methods. This allows for a lot more flexibility as you can do all the same stuff with class methods as you can with instance methods, such as nil messaging, method swizzling etc.