I have read about method hiding concept in Java but I am not sure I understand the advantages. In which cases would method hiding be useful?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can read more here http://docs.oracle.com/javase/tutorial/java/IandI/override.html
In short, the benefit is that you can implement a static method in a subclass which has the same signature as a static method in a superclass. If you could not do this, you couldn’t add such methods to sub classes, and if you added such a method to a superclass all its subclasses would fail to compile.
BTW: You can make a static method not allow hiding by making it final.
to allow a method to be hidden you can make it non-final