I am trying to use the inheritance concept where I inherit my data from the super class using GUI in Netbeans. I want the button in the form to display the information i got from the super class. However,i am getting the 'Void cannot be allowed' error. Can you help me solve this?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
House myHouse = new House(8);
JOptionPane.showMessageDialog(null,myHouse.displayHouseDetails());
}
UPDATE
public class Building {
protected String size;
protected double price;
public Building(String size,double price)
{ this.size = size;
this.price = price;
}
}
public class House extends Building{
private int houseNo;
public House(int houseNo)
{ super("100 X 90",100000);
this.houseNo = houseNo;
}
public void displayHouseDetails(){
System.out.println("House no:"+houseNo);
System.out.println("Size:"+size);
System.out.println("Price:"+price);
}
btw, may I know how can i make my button to display the data that inherit from super class?