This post originated from an RSS feed registered with Java Buzz
by Javin Paul.
Original Post: What is rule of overloading and overriding in Java
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Overloading
and overriding rule in Java Since you can either overload or override methods in Java, its important
to know what are the rules of overloading
and overriding in Java. any overloaded
method or overridden
method must follow rules of method overloading and method overriding to
avoid compile time error and logical error, where you intend to override a
method, instead method got overloaded. That is not uncommon and happen several
times when Java programmer tries to override
equals in Java or overriding
compareTo method in Java while implementing Comparable interface,
which accepts Object type of argument. From Java 5 onwards which introduces @Override annotation along with Enum,
Generics
and varargs
method you can completely avoid that problem. Anyway, let's see rules of
method overloading and rule of method overriding in Java.