Point Note that I may not include all these comments in my sample code, but you should plan to. A close brace You can also preface the return type with a number of modifiers, which we'll come back to later. To call the method associated with an object, you use the object's name a period the method's name an open paren the paremeters to the method a close paren Note that this is somewhat different than in a language like C or Pascal, in which the object would be one of the parameters. Here's our sample class, extended with three methods, one to set the parts, one to get the real part, and one to get the imaginary part. Classes can include constructors that describe how to create such objects.
Constructors can have parameters that are used in the initialization of the object.
Constructors look very much like methods, with the difference that they have the same name as the class. This is particularly important for constructors, as there are many different ways that we may want to describe a new object. A constructor that takes both x and y values. If you don't declare any constructors, Java uses a default constructor with no parameters. If you do declare constructors, that default constructors is no longer available.