Learning Java programming

Discussion in 'Computer Games and General Discussion' started by zuron7, Mar 4, 2011.

  1. zuron7
    OP

    zuron7 RBYG

    Member
    1,369
    3
    Apr 6, 2009
    India
    GPS not available in this area
  2. Invisible Man

    Invisible Man Member

    Newcomer
    17
    0
    Oct 31, 2010
    United States
    CODEclass AreaRectangle {
    double x;
    double y;

    AreaRectangle() {
    this.x = 4;
    this.y = 2.3;
    }

    void calAreaRectangle() {
    double a = this.x * this.y;
    double b = 0;
    System.out.print("The area of the Rectangle is " + a + ". It's length is " + this.x + ". It's breadth is " + b);
    }
    }

    public class Main {
    public static void main(String args[]) {
    AreaRectangle A = new AreaRectangle();
    A.calAreaRectangle();
    }
    }

    ?
     
  3. tj_cool

    tj_cool Site dev

    Supervisor
    9,989
    -1
    Jan 7, 2009
    Belgium
    This planet
    You forgot a } on the end.

    That's why you should format the code, like above.
     
  4. Invisible Man

    Invisible Man Member

    Newcomer
    17
    0
    Oct 31, 2010
    United States
    And also:
    • b wasn't defined
    • "main(String args[])" doesn't seem suitable in the AreaRectangle class.
    Also the poster should consider using a IDE for help with detecting these errors and formatting the code better, may I suggest NetBeans.
     
  5. mollekemiel

    mollekemiel Advanced Member

    Newcomer
    72
    2
    May 9, 2006
    United States
  6. zuron7
    OP

    zuron7 RBYG

    Member
    1,369
    3
    Apr 6, 2009
    India
    GPS not available in this area
    Thanks!
    And another thing could someone link me to a good site to learn java.