這裏引用是錯誤消息非靜態方法...不能從靜態上下文
non static method hero(double,double,double) cannot be reference from a static context
下面是類方法。
class MyMath {
double hero(double n1, double n2, double n3)
{
double n4;
double n5;
n4 = (n1 + n2 + n3)/2;
n5 = Math.sqrt((n4 * (n4 - n1) * (n4 - n2) * (n4 - n3)));
return n5;
}
}
這裏是主程序
static double hero(double n1, double n2, double n3){...}
[Java - 對非靜態字段列表進行靜態引用]的可能重複(http://stackoverflow.com/questions/10200740/java-making-a-static-reference-to-the-non-靜態字段列表) – Perception 2012-04-18 06:36:04