简体   繁体   English

如何使用 Visual Studio Code 在 Java 中导入东西

[英]How to import stuff in java with Visual Studio Code

Im new with Java and i'm struggling with packages and classes when it comes to imports.我是 Java 新手,在导入时我正在努力处理包和类。 So i want to do something simple :所以我想做一些简单的事情:

I want to include my class that takes inputs from the user, but somehow it keeps giving me all sorts of errors.我想包括我的类,它接受用户的输入,但不知何故它不断给我各种错误。

在此处输入图片说明

In Java, to be part of a package, you both need to be inside the correct folder, and start the file with package myclass;在 Java 中,要成为包的一部分,你们都需要在正确的文件夹中,并以package myclass;开始文件package myclass; . . You didn't show us the source code for Clavier.java but my educated guess is that you didn't start it with package myclass;您没有向我们展示Clavier.java的源代码,但我有根据的猜测是您没有使用package myclass;启动它package myclass; . .

As a side note, myclass is a really bad and confusing name for a package (which isn't a class).附带说明一下,对于包(不是类)来说, myclass是一个非常糟糕且令人困惑的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM