So I'm new to Java and would really like some suggestions here.
I have a jar XYZ.jar
which I've added to my classpath. This XYZ.jar
has some 4 classes namely A,B,C,D
. There is a method in CLASS D
namely private void METHOD P()
which is being called by CLASSES A,B,C
.
Now I have a class Main.java
in my project
which is having a method METHOD R().
Now I would like to override private void METHOD P()
with METHOD R()
present in my Main.java
. One thing I can do is that, I can extend my Main class
with CLASS D
. But, I would then have to modify the methodnames in CLASSES A,B,C
which I don't want to do as the said classes are inside the jar.
So, what I would like to know is whether there's a way to override a private method of a class present inside a jar without making any changes to the rest of the classes calling the method, present inside the jar.