I have a class A:
A
- void method1
And a class B that extends A that overrides A's method1:
B->A
- void method1
Later on, I create an instance of B that is referenced as an A:
A a = new B();
I want to use A's version of method1 in a specific case. Is there a way to call this, like:
a.super.method1();
Edit:
To clear up any confusion, here is what I am trying to accomplish:
I have a parent class called Account. Beneath that I have 3 subclasses, SavingsAccount, CheckingAccount, and MoneyMarketAccount.
Each of these has its own deposit/withdraw methods that have specific fees associated to them.
There is a manager class called Bank that has an ArrayList of Account objects in it. I have a method, void transfer that I am attempting to create that will allow me to take the two accounts and transfer the money between them.
Sometimes the different methods will throw exceptions if there are insufficient funds or other errors, so I need to be able to reverse a transaction if it fails for one of the two accounts.
This is where I am having problems:
I need to redeposit the money withdrawn from the from-account if the to-account can't receive deposits, but the to-account may have deposit fees, so I would like to just call the parent Account class's deposit method, as it does not have any fees associated; however, from the comments and answers that I have received, I may have to just write another method that is not overridden that simply performs the same operation as Account's deposit.
super.method1()inB.a.anotherMethodInB()because I don't know that it is a B.overloadandoverride. What you meant in this question is methodoverride.