I am trying to calculate the area of the circle using class and object in Java, but the output is not as I want. I want an answer as 78.5 but the area = 0.0, why? Here is the code below-
package com.company;
import java.util.Scanner;
class Circle{
    double r;
    double area= Math.PI*r*r;
}
public class practice {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Circle c = new Circle();
        System.out.print("Enter the radius of circle: ");
        c.r = sc.nextDouble();
        System.out.println("The area of circle is: "+ c.area);
    }
}
The result I got is-
Enter the radius of circle: 5
The area of circle is: 0.0
Process finished with exit code 0
 
     
     
    