0

我正在尝试在 java 中的 main 方法中创建方法,但是当我尝试启动新方法时,每行都会出现错误“Illegal start of statement”。这是我的程序。

导入 java.util.*;导入java.lang.Math;

公共类circlerisk {

final static double PI = 3.14156;

public static void main(String [] args)
{
    double x1;
    double y1;
    double x2;
    double y2;
    double radius;
    double circumference;
    double area;

    Scanner console = new Scanner(System.in);

    System.out.println("Please enter x1");

    x1 = console.nextDouble();

    System.out.println("Please enter y1");

    y1 = console.nextDouble();

    System.out.println("Please enter x2");

    x2 = console.nextDouble();

    System.out.println("Please enter y2");

    y2 = console.nextDouble();



    public static double distance(double x1, double y1, double x2, double y2)
{
    double dx,dy,d;
    dx = x2 - x1;
    dy = y2 - y1;
    d = Math.sqrt(dx*dx+dy*dy);
    return d;


}//distance


public static double radius(double x1, double y1, double x2, double y2)
{

    radius = d;
    return radius;
}

public static double circumference(double radius)
{
    circumference = (radius*2*PI);
    return circumference;
}

public static double area(double radius;)
{
    area = (radius*radius*PI);
    return area;
}



}//main

}//班级

4

1 回答 1

0

您根本无法在 Java 中嵌套方法。在定义下一个方法之前,您需要关闭 main 的主体。

于 2013-10-29T22:17:03.030 回答