"Shadowplay" <An*************@hugeass.com> wrote in message news:<Wb********************@comcast.com>...
Could someone give me a good definition and an example of a constructor?
I'm having problems trying to understand it. I thought it was just a way to
initialize variables in a class but I guess it does much more than that.
Any websites that might help would be appreciated.
initialize variables in a class
variables in an object
In the beginning you load class onto JVM memory. There's no object at
that moment. Then a static method in the class, typically main()
method, creates an object of the class or of some other class by
calling:
Foo f = new Foo();
This 'new' operator calls constructor of the Foo class. If you don't
write any constructor for your class, Java provides minimum barebone
one automatically.