Hi all I am enrolled in abeginners class and am having problems with methods. I keep getting a .class expected and do not know how to fix this. It is at this line that the message appears total = Circle.area(int radius);.

import javax.swing.JOptionPane;

public class Circle
   public static void main(String [] args)
      // double area; ////area to be determined in a method
       double radius; //radius inputted by user
       String input; //for holding user input    
       double total;//final area of a circle

       //Ask the user for a radius or a circle
     input= JOptionPane.showInputDialog("Please enter the radius of the circle ");

       //Convet the string input to a double

       // this calls the circle method
       total = Circle.area(int radius);

       JOptionPane.showMessageDialog(null,"The area of the circle is "+total );
        * The Area method returns the area of the circle
        * @param rad the radius inputted by the user
        * @param Math.PI the math class
        * @return The area of the circle
       public  static double area (double rad)
         double area;
         area=Math.PI * (rad*rad);
         return area;


Edited by mike_2000_17: Fixed formatting

7 Years
Discussion Span
Last Post by Colin454

I fixed the int in the method call to a double and it still will not work


remove the "int" and/or "double" now, from the call to the method. You include types when defining and declaring the methods. You include only values when calling the methods.

Edited by masijade: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.