Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用以下方法创建一个新路径:
Path path = new Paths.get(path_name);
我已经导入了Path和Paths并且我已经确认方法get存在于 Paths 中,但是 Eclipse 告诉我该方法不存在。它说:Paths.get 无法解析为类型 我该怎么办?我重新启动了 Eclipse 和我的电脑,但仍然没有运气。提前致谢。
get(..)是一种静态方法。像这样称呼它:
get(..)
Path path = Paths.get(path_name);
引用:“此类仅由静态方法组成” API
您的代码片段不正确:调用静态方法不需要new
new
Path path = Paths.get(path_name); // get(...) is a static method