令牌上的java Sytnax错误,构造位置错误
我在做一个计算机科学的作业,我有几个错误。我不得不上传代码,因为我无法让它在Stackoverflow上工作。这是链接:http://txt.do/tqmh
以下是错误:
16 errors found:
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 15]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 15]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 32]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 32]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 57]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 57]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 83]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 83]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 112]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 112]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 137]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 137]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 161]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 161]
Error: Syntax error on token "int", @ expected
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 184]
Error: Syntax error on token(s), misplaced construct(s)
File: C:\Users\Om\Desktop\CYOA_Om_Malhar.java [line: 184]
Error: Syntax error on token "int", @ expected
请帮忙
# 1 楼答案
正如已经发布的,在主方法中有静态方法,这是根本错误的。你不能在一个方法中有一个方法——除非它在匿名类中(但我们不要讨论这个)。因此,首先要删除
main(String[] args).
中的所有方法例如,你应该
另外,如果您想将参数传递给一个方法,我可以看到您需要为if语句传递参数,您可以通过这样做,即
# 2 楼答案
我不明白您想做什么,但此代码应该可以工作: