私はいつもn00bの質問をしているので申し訳ありませんが、私は本当に助けを使うことができました. とにかく、特定の長さの単語のみを辞書からハッシュセットである変数の単語にインポートしようとしています。プログラムを実行して、文字列のハッシュセットとも呼ばれる単語を出力しようとすると。コンソールに何も表示されず、プログラムの実行が停止しません。どうすればこれを修正できますか? PSまた、JOptionPaneコードの一部が十分にカットされていることは知っていますが、エラーはなく、要点がわかります。ありがとう!アレックス
public void inputWords()
{
try
{
frame = new JFrame("Hangman");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame.setVisible(true);
input = new Scanner(new FileInputStream("dictionary.txt"));
wordLength = Integer.parseInt( JOptionPane.showInputDialog(null,
String importedWords = input.nextLine();
while(stillHasWords==true)
{
if(importedWords.length()==wordLength)
{
words.add(importedWords);
}
else
{
}
}
}
catch(FileNotFoundException f)
{
System.out.println("File does not exist.");
System.exit(0);
}
catch(NoSuchElementException q)
{
stillHasWords=false;
}
public static void main(String[] args)
{
EvilHangman j = new EvilHangman();
System.out.println(stillHasWords);
j.inputWords();
System.out.println(words + " ");
}
}