【问题标题】:I am new to coding and watching a tutorial. These lines work in the tutorial, but Eclipse keeps telling me there is an error [duplicate]我是编码和观看教程的新手。这些行在教程中有效,但 Eclipse 一直告诉我有一个错误 [重复]
【发布时间】:2021-01-28 07:30:40
【问题描述】:
public class LearnJava {

    public static void main(String[] args) {
        name = "Susan";
        System.out.println(name.toUpperCase());
    }
}

启动层初始化时出错 java.lang.module.FindException:读取模块时出错:D:\java\JavaTutorial\bin 原因:java.lang.module.InvalidModuleDescriptorException: LearnJava.class found in top-level directory (未命名的包不允许在模块中)

【问题讨论】:

  • 需要声明变量name
  • 应该是String name = "Susan";

标签: java


【解决方案1】:
public class LearnJava {

    public static void main(String[] args) {
        String name = "Susan";
        System.out.println(name.toUpperCase());
    }
}

【讨论】:

  • 虽然改变是必要的,但它并不能解决 OP 询问的问题。 (提示:阅读整个问题,而不仅仅是代码。)
  • 请描述您的解决方案,而不仅仅是删除代码
  • 社区鼓励在代码中添加解释,而不是纯粹基于代码的答案(参见here)。
猜你喜欢
  • 2011-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-10
相关资源
最近更新 更多