You can extend the class with one of your classes and then use @Override to create a new version of the method. You would then use your class as if it were the class you extended: It has the same methods and functionality, except for the methods you have overridden.
An example could look like this:
Class a:
Public class A{
public void printName(){
System.out.println("A");
}
public void test(){
System.out.println("test");
}
}
Class B:
public class B extends A{
@Override
public void printName(){
System.out.println("B");
}
}
Main:
public static void main(String[] args){
B b = new B();
A a = new A();
a.printName(); -------- A
b.printName(); -------- B
b.test(); -------- test
a.test(); -------- test
}
1
solved How can I replicate this method to a method without the parameters?