模块中的 Eclipse 错误,我的格式不正确吗?
Eclipse error in module, am I not formatting correctly?
在 Eclipse 中,我收到了
的错误代码
'Syntax error on token(s), misplaced construct(s)'
我不太明白模块应该如何格式化,希望有人能解释我做错了什么。
module math{
class DoMath{
public void main(String[] arguments) {
double score = 1.0 + 2.0 * 3.0;
System.out.println(score);
score = score / 2.0;
System.out.println(score);
}
}
}
我认为您误解了 module
的用法这里是 link 解释 java 中的新模块系统。
也许您想将 class 与 package
相关联?
package com.mycompany.math;
public class DoMath {
public void main(String[] arguments) {
double score = 1.0 + 2.0 * 3.0;
System.out.println(score);
score = score / 2.0;
System.out.println(score);
}
}
然后您可以声明一个 module
(一个模块-info.java 文件)
module mathModule {
exports com.mycompany.math;
}
在 Eclipse 中,我收到了
的错误代码'Syntax error on token(s), misplaced construct(s)'
我不太明白模块应该如何格式化,希望有人能解释我做错了什么。
module math{
class DoMath{
public void main(String[] arguments) {
double score = 1.0 + 2.0 * 3.0;
System.out.println(score);
score = score / 2.0;
System.out.println(score);
}
}
}
我认为您误解了 module
的用法这里是 link 解释 java 中的新模块系统。
也许您想将 class 与 package
相关联?
package com.mycompany.math;
public class DoMath {
public void main(String[] arguments) {
double score = 1.0 + 2.0 * 3.0;
System.out.println(score);
score = score / 2.0;
System.out.println(score);
}
}
然后您可以声明一个 module
(一个模块-info.java 文件)
module mathModule {
exports com.mycompany.math;
}