I am developing a Java application using a specific library (included using a jar file) I want to override the method contained in that library on a class (abstract class), or a certain parameter value changes in it, is there a way to do this?
Extend the category from which you want to override the law. Public class ClassFromExtLib {public void foo {object}} {}} Public class MyClass Extended to ClassFromExtLib {@ Override Public void foo (Object Ultimate) {super.foo (Ultimate); // Adding your own implementation ...}} If you can not expand the square, then use a wrapper class that can execute the method and After that you can add your own logic. / P>
Public Ultimate Classroom ClassFromExtLib {Public Zero Foo (Object Ultimate) {}} Public class MyClass {// code to start the example of ommited private classFromExtLib bar; Public Zero Foo (Object Ultimate) {bar.foo (Ultimate); // Adding your own implementation ...} Public Zero Foo (Object Ultimate, Object Ultimate 2) {bar.foo (param); // Adding your own implementation using the param and param2 ...}} If you want to add / remove parameters in the method, you can not override it , This is an overloading second way would be best for you.
No comments:
Post a Comment