Read-only computed properties in Java
Forums:
class Сircle {
public double radius;
//In Java there are no properties
public double getArea() {
return 2 * Math.PI * radius;
}
}
Сircle circle = new Сircle();
circle.radius = 2;
double area = circle.getArea();
//area is 12.56
- Log in to post comments