Why won't my public void Constructor {} compile?

前端 未结 1 1778
暗喜
暗喜 2020-11-28 16:59

I have an assignment that requires a bank account to be able to transfer funds from a checking and savings account. The transactions are stored in an ArrayList and set up fo

相关标签:
1条回答
  • 2020-11-28 17:16

    Constructors have no return type. So not

    // this is a "pseudo"-constructor
    public void TransferService(){
    

    but rather

    // this is the real deal
    public TransferService(){
    

    Regarding,

    Transaction is abstract and cannot be instantiated

    Well, is it? Is the Transaction class an abstract class or an interface? Only you who has the code knows the answer to this. If this is true, then you'll need to use a concrete implementation of Transaction in your code.

    0 讨论(0)
提交回复
热议问题