View RSS Feed

Java Object

Object-oriented programming in Java.

  1. Overloading on return values

    by , 04-26-2012 at 06:39 PM
    It is commonly wondered that why method argument & class names lists? Why methods shall not be distinguished ,based at return values? E.g, two methods having similar arguments and name get distinguished quite easily from each other:

    void f() {}
    int f() {}

    It will be working fine if unequivocally a compiler finds out the meaning, as in int x = f( ). But, a method could be called and return value can be ignored; which is referred as method calling for sideeffects, ...
  2. Using Name Hiding for Overriding

    by , 11-30-2011 at 03:45 AM
    Sometimes you will have a java base class that has a method thatís been overloaded several times. It is important for the programmer to remember that redefining the method name in the derived class does not hide any of the base-class versions. Therefore you should keep in mind that overloading works irrespective of whether the method has been defined at this level or in a base class:

    Java Code:
    import static com.acme.examples.Print.*;
    public class Mother {
    	char foo(char