This question already has an answer here:
这个问题在这里已有答案:
- What does a “Cannot find symbol” compilation error mean? 10 answers
“无法找到符号”编译错误是什么意思? 10个答案
I'm getting a Java: 10: error for line 7, when I compile the code listed below. This is sample given to us for this weeks assignment to tailor to meet requirements of the project and I know this same code has popped up repeated on Stack.
当我编译下面列出的代码时,我得到了Java:10:第7行的错误。这是给我们这个星期分配的样本,以便量身定制以满足项目的要求,我知道在Stack上重复出现了相同的代码。
import javax.swing.JOptionPane;
public class ProjectTwo
{
public static void main(String[] args)
{
String input;
input = JOptionPane.showInputDialog("Enter a password.");
if (!PasswordVerifier.isValid(input))
JOptionPane.showMessageDialog(null, "Invalid password.");
else
JOptionPane.showMessageDialog(null, "Valid password.");
System.exit(0);
}
}
Based off the error, I believe I haven't imported the correct utility to use the PasswordVerifier
function. I've been digging through:
根据错误,我相信我没有导入正确的实用程序来使用PasswordVerifier函数。我一直在挖掘:
- docs.oracle.com
to find possibly what element of javax.swing is applicable to import, with no luck. Any help would be greatly appreciated.
找到可能javax.swing的哪个元素适用于导入,没有运气。任何帮助将不胜感激。
1 个解决方案
#1
3
There should be an import statement for PasswordVerifier? For example.
PasswordVerifier应该有一个import语句?例如。
import com.package.PasswordVerifier
Example of my output when I ran your code
我运行代码时输出的示例
C:\Users\Aaron\Documents\ProjectTwo.java:9: error: cannot find symbol
if (!PasswordVerifier.isValid(input))
^
symbol: variable PasswordVerifier
location: class ProjectTwo
1 error
#1
3
There should be an import statement for PasswordVerifier? For example.
PasswordVerifier应该有一个import语句?例如。
import com.package.PasswordVerifier
Example of my output when I ran your code
我运行代码时输出的示例
C:\Users\Aaron\Documents\ProjectTwo.java:9: error: cannot find symbol
if (!PasswordVerifier.isValid(input))
^
symbol: variable PasswordVerifier
location: class ProjectTwo
1 error