항상 n00b 질문을하고 있기 때문에 사과드립니다.하지만 실제로 도움을받을 수 있습니다. 어쨌든 사전에서 특정 길이의 단어 만 해시 집합 인 변수 단어로 가져 오려고합니다. 프로그램을 실행하고 내 단어를 일컬어 문자열의 해시 세트를 인쇄하려고 할 때. 나는 콘솔에서 아무 것도 얻지 못하고 프로그램이 멈추지 않는다. 이 문제를 어떻게 해결할 수 있습니까? 추신 또한 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 + " ");
}
}
catch (NoSuchElementException q)의 단어가 여전히 변경되었습니다. – Amloelxer
@Amloelxer : 편집을 참조하십시오. –
정말 고마워요! 죄송합니다. "나는 당신이 무엇이 될지 추측하게 만들었습니다." 다음 번에 더 좋은 질문을 올리겠습니다. – Amloelxer