View RSS Feed

Recent Blogs Posts

  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
    ...
  3. How to do Overloading with Generics

    by , 11-29-2011 at 05:12 PM
    Overloading is a technique often used in object orientated programming languages such as java. In the context of generics unfortunately, classic type of overloading will produce a compile time error because of erasure.

    Java Code:
    import java.util.List;
    
    public class OverloadingExample<W, T> {
    	void f(List<T> v) {
    	}
    
    	void f(List<W> v) {
    	}
    }

    What you must do to overcome this problem is to provide ...