Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Class & Constructor Won't Compile

Learning Class and constructor from web, kind of copy and modify Class and constructor to caculate Area. But it won't compile. Thanks
--- --- ---
/* Define a Class with Constructor */
/* Calculate Area of Football Field and Basketball Court */

public class Area {
int length;
int width;
public int getArea () { // Method to calc Area
reture (length*width);
}

Area() { //First Kind Of Constructor
length=110;
width=50;
}

Area(int l, int w) { //2nd Kind Of Constructor
length = l;
width = w;
}

Public static void main(String[] args) {
Area fField, bCourt;
fField = new Area();
bCourt = new Area(40,30);

System.out.println("footballField Area is " + fField.getArea());
System.out.println("basketballCourt Area is " + bCourt.getArea());
}
}
=== compile error ===
D:java-code>javac consExecise.java
consExecise.java:21: expected
Public static void main(String[] args) {
^
1 error

Comments

  • jhuwalkerjhuwalker Member Posts: 5
    /* Define a Class with Constructor */
    /* Calculate Area of Football Field and Basketball Court */

    public class consArea {
    int length;
    int width;
    public int getArea () { // Method to calc Area
    reture (length*width);
    }

    consArea() { //First Kind Of Constructor
    length=110;
    width=50;
    }

    consArea(int l, int w) { //2nd Kind Of Constructor
    length = l;
    width = w;
    }

    public static void main(String[] args) {
    consArea fField, bCourt;
    fField = new consArea();
    bCourt = new consArea(40,30);

    System.out.println("footballField Area is " + fField.getArea());
    System.out.println("basketballCourt Area is " + bCourt.getArea());
    }
    }
    ========= Error ===
    D:java-code>javac consArea.java
    consArea.java:8: cannot find symbol
    symbol : method reture(int)
    location: class consArea
    reture (length*width);
    ^
    1 error

Sign In or Register to comment.