Learning Java programming

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

Mar 4, 2011

Learning Java programming by zuron7 at 11:49 AM (738 Views / 0 Likes) 5 replies

  1. zuron7
    OP

    Member zuron7 RBYG

    Joined:
    Apr 6, 2009
    Messages:
    1,369
    Location:
    GPS not available in this area
    Country:
    India
  2. Invisible Man

    Newcomer Invisible Man Member

    Joined:
    Oct 31, 2010
    Messages:
    17
    Country:
    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

    Supervisor tj_cool Stuff

    Joined:
    Jan 7, 2009
    Messages:
    9,942
    Location:
    This planet
    Country:
    Belgium
    You forgot a } on the end.

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

    Newcomer Invisible Man Member

    Joined:
    Oct 31, 2010
    Messages:
    17
    Country:
    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

    Newcomer mollekemiel Advanced Member

    Joined:
    May 9, 2006
    Messages:
    72
    Country:
    United States
  6. zuron7
    OP

    Member zuron7 RBYG

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

Share This Page