As we know, we do not need to add any type of return value to the Java constructor.
class Sample{ ..... Sample(){ ........ } }
In Objective-C, if we create a constructor, it returns a pointer to its class. But I do not think this is not necessary.
AClass *anObject = [[AClass alloc] init];
Similarly, the constructor is converted to a method that returns a reference to its own class?
Like this:
class Sample{ ..... Sample Sample(){ ........ return this; } }
Does the compiler make the return type a reference to the same class as the constructor? What happens to the constructor? Any link to learn this?
EDIT:
In fact, I want the answers to be at the bytecode level or the JVM level or even lower.
java constructor jvm bytecode
sonu thomas Jan 15 '12 at 7:08 2012-01-15 07:08
source share