0% found this document useful (0 votes)
6 views1 page

Java Rectangle Class Implementation

The document defines a Rectangle class with private length and width variables. It includes methods to set the length and width, get the length and width, and calculate the area by multiplying length times width. The main method creates two rectangle objects, sets their length and width values, and does not perform any additional operations.

Uploaded by

Ahmed Mohammed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Java Rectangle Class Implementation

The document defines a Rectangle class with private length and width variables. It includes methods to set the length and width, get the length and width, and calculate the area by multiplying length times width. The main method creates two rectangle objects, sets their length and width values, and does not perform any additional operations.

Uploaded by

Ahmed Mohammed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

public class rectangle{

private double length;


private double width;
public void setlnegth(double 1)
{
length =1;
}

public void setwidth(double w)


{
width = w;
}
public double getlength()
{
return length;
}
public double getwidth()
{
return width;
}
public double getarea()
{
return length * width;
}
}

public static void main(String[]args){


rectangle r1=new rectangle();
[Link](10.5);
[Link](1.2);

rectangle r2 = new rectangle();


[Link](15);
[Link](20);

You might also like