gpt4 book ai didi

java - token 语法错误 "(", ; token ","上的预期语法错误,; token ")"上的预期语法错误,;预期的

转载 作者:行者123 更新时间:2023-12-02 06:53:34 25 4
gpt4 key购买 nike

我正在开发一个项目,只是为了为 java 开发人员测试 eclipse IDE。我是java新手,所以我想知道为什么它不起作用,因为我已经知道该怎么做了。这是代码:

public class eclipse {

public static double main(String[] args) {
// TODO Auto-generated method stub
final double average(double number, double number2)
{
double number3 = (number + number2)/2;
return number3;
}
final double suk(double number4, double number5)
{
double number6 = number4 + number5;
return number6;
}
final double differenck(double number7, double number8)
{
double number9 = number7 - number8;
return number9;
}
final double produck(double number10, double number11)
{
double number12 = number10*number11;
return number12;
}
}
}

这是出现的错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
Syntax error on token "(", ; expected
Syntax error on token ",", ; expected
Syntax error on token ")", ; expected
Void methods cannot return a value
Syntax error on token "(", ; expected
Syntax error on token ",", ; expected
Syntax error on token ")", ; expected
Void methods cannot return a value
Syntax error on token "(", ; expected
Syntax error on token ",", ; expected
Syntax error on token ")", ; expected
Void methods cannot return a value
Syntax error on token "(", ; expected
Syntax error on token ",", ; expected
Syntax error on token ")", ; expected
Void methods cannot return a value

最佳答案

您正在主方法中编写所有方法。请从 main 方法中删除所有方法

public static void main(String[] args) {
//do something

}

final double average(double number, double number2)
{
double number3 = (number + number2)/2;
return number3;
}
final double suk(double number4, double number5)
{
double number6 = number4 + number5;
return number6;
}
final double differenck(double number7, double number8)
{
double number9 = number7 - number8;
return number9;
}
final double produck(double number10, double number11)
{
double number12 = number10*number11;
return number12;
}

并且main方法的return类型应该是void

关于java - token 语法错误 "(", ; token ","上的预期语法错误,; token ")"上的预期语法错误,;预期的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17701282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com