Home > Back-end >  JAVA programming area is what oh? Crab crab wow have a big help
JAVA programming area is what oh? Crab crab wow have a big help

Time:09-20

Define a class, attribute has radius r, there are ways to area (), function is the area of the computer, the other contains a constructor parameter, write the main function, the definition of a radius of three circle, calculated that the area of a circle,

CodePudding user response:

Public class Circle {
Private double r;
Public Circle (double r) {this. R=r; }
Public double area () {return 3.1415926 * r * r; }
Public static void main (String [] args) {
Circle c=new Circle (3);
System. The out. Println (c.a. rea ());
}
}
  • Related