JAVA 相关问题求助!

来源:百度知道 编辑:UC知道 时间:2024/06/23 13:36:06
请问以下这段代码为什么错误呢??
class Test
{
public static void main(String[] args)
{
double A(double x,double y)
{
return x-y;
}
}
}
为什么呢??

public class Test {

/**
* @param args
*/
public static void main(String[] args) {
double x=1.9;
double y=2.9;
System.out.print(A(x,y));

}
public static double A(double x,double y)
{
return x-y;
}

}

这个是java比较基础的知识。
public static void main(String[] args) 所以函数也要是静态的。

A方法应该放在main方法外面

我已经无话可说了, 强烈支持楼上.

如果能运行就是见鬼了。

慢慢来 开始不知道很正常 大家都是那么走过来的

class Test
{
double A(double x,double y)
{
return x-y;
}

public static void main(String[] args)
{
Test t=new Test();
t.A();

}
}
应该这样就OK了,方法里面是不能够再套个方法的!