Re: Obj-C vs Java
Re: Obj-C vs Java
- Subject: Re: Obj-C vs Java
- From: Enrique Zamudio <email@hidden>
- Date: Tue, 24 Jul 2001 10:35:34 -0500
- Organization: Nasoft
Bernard van Gastel wrote:
>
Thanks. I wasn't aware of the static issue when subclassing (though I
>
have 2 years Java experience, guess I have never run into it). I am a
>
bit confussed about class methods. What is the diffenence with static
>
Java methods (not counting the subclassing issue)?
>
I think that would be the main difference. For example, a class method of
everyday use is +alloc, which returns a new instance of the class you send
the message to.
Another difference is that you can use the self variable in class methods and
it will refer to the class object.
You cannot access instance variables from within class methods.
If you do something like [[self class] alloc] or something similar in a class
method, when the method is called on subclasses then [self class] will return
the subclass, thus allowing for inheritance of class methods. You can extend
class methods by calling super when you override them (this is very important
and you can't do it in Java).
eZL