Answers for "how to calculate rectangle area in java using class and object"

2

Calculate area of rectangle using class in java

// calculate area of rectangle using class in java
import java.io.*;
class RectangleShape 
{
   int length, breadth; 
   void setValue(int l, int b) 
   { 
       length = l; 
       breadth = b; 
   }
   // get area of rectangle
   int findArea() 
   { 
       return (length * breadth); 
   }
}
public class RectangleAreaDemo
{
   public static void main(String[] args)
   {
      RectangleJava obj = new RectangleJava(); 
      obj.setValue(10, 5); 
      System.out.println("Area of rectangle: " + obj.findArea());
   }
}
Posted by: Guest on February-09-2021

Code answers related to "how to calculate rectangle area in java using class and object"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language