compiler say invalid method declaration return type required
how can i have a return type in my constructor?. that does not make any sense. i have never seen a constructor asking for a return type why my compiler gives me this error?
here is my investmentdeposit class
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class InvestmentDepositextends JFrame{
privatestaticfinalint FRAME_HEIGHT = 350;
privatestaticfinalint FRAME_WIDTH = 250;
privatestaticfinaldouble DEFAULT_RATE = 5;
privatestaticfinaldouble INITIAL_BALANCE = 1000;
private JTextField withdrawField;
private JTextField depositField;
private BankAccount account;
private JLabel rateLabel;
private JLabel resultLabel;
private JLabel depositLabel;
private JPanel panel;
private JButton button;
private JButton button1;
public InvestmentDepsoit(){
account =new BankAccount(INITIAL_BALANCE);
resultLabel =new JLabel("Balance: " + account.getBalance());
createTextField();
createWithdrawButton();
createDepositButton();
createPanel();
setSize(FRAME_WIDTH, FRAME_HEIGHT);
}
privatevoid createTextField(){
rateLabel =new JLabel("Withdraw Money ");
finalint FIELD_WIDTH = 10;
withdrawField =new JTextField(FIELD_WIDTH);
withdrawField.setText("" + DEFAULT_RATE);
depositLabel =new JLabel("Add Money ");
depositField =new JTextField(FIELD_WIDTH);
depositField.setText("" + DEFAULT_RATE);
}
privatevoid createWithdrawButton(){
button =new JButton("Withdraw");
class AddWithdrawListenerimplements ActionListener{
publicvoid actionPerformed(ActionEvent event){
double value = Double.parseDouble(withdrawField.getText());
account.withdraw(value);
resultLabel.setText("Balance: " + account.getBalance());
}
}
ActionListener listener =new AddWithdrawListener();
button.addActionListener(listener);
}
privatevoid createDepositButton(){
button1 =new JButton("Deposit ");
class AddDepositListenerimplements ActionListener{
publicvoid actionPerformed(ActionEvent event){
double value = Double.parseDouble(depositField.getText());
account.deposit(value);
resultLabel.setText("Balance " + account.getBalance());
}
}
ActionListener listener =new AddDepositListener();
button1.addActionListener(listener);
}
privatevoid createPanel(){
panel =new JPanel();
panel.add(rateLabel);
panel.add(withdrawField);
panel.add(button);
panel.add(depositLabel);
panel.add(depositField);
panel.add(button1);
panel.add(resultLabel);
add(panel);
}
}
here is the error
C:\Java programs\ch14\Investment2\InvestmentDeposit.java:20: invalid method declaration;return type required
public InvestmentDepsoit(){
^
1 error

