Gaming Learning Java programming

Invisible Man

Member
Newcomer
Joined
Oct 31, 2010
Messages
17
Trophies
0
XP
33
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();
}
}

?
 

Invisible Man

Member
Newcomer
Joined
Oct 31, 2010
Messages
17
Trophies
0
XP
33
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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    NinStar @ NinStar: It will actually make it worse