Saturday, January 26, 2008

Java Programming - Using the this keyword

Within an instance method or a constructor, this is a reference to the current object - the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this.

Java Programming - Returning a Value from a Method

A method returns to the code that invoked it when it completes all the statements in the method, reaches a return statement, or throws an exception, whichever occurs first.

You declare a method's return type in its method declaration. Within the body of the method, you use the return statement to return the value.

Any method declared void doesn't return a value. It does not need to contain a return statement, but it may do so.