Originally posted by Jenny Yin:
Can anyone kindly tell me what an initializaer is? Can anyone give an example?
Thanks,
Jenny
Here's one more example for you in the context of a full class:
I was in a hurry, so I didn't
test this, but
you should see the output given above.
Instance initializers aren't really very different from a constructor. The main use for them is to either combine common code that would be used in multiple constructors or to perform initialization for an anonymous class, which, as it has no name, has no constructor.
I hope that helps,
Corey