文字列を取得し、区切り文字に基づいて2つの文字列に分割することになっているvoidメソッドがあります。デバッガーを使用したことで、メソッドは正しく機能しているように見えますが、結果を格納するメソッドに渡す2つの空の文字列は更新されていないようです。私はここで何かばかげたことをしているに違いありませんが、どんな助けでもありがたいです!
public static void main(String[] args) {
String dictFile = "/Users/simonrhillary/Desktop/Dictionary(3).txt";
String synFile = "/Users/simonrhillary/Desktop/Synonyms(2).txt";
fileReader dictFR = new fileReader();
fileReader synFR = new fileReader();
dictFR.filePath = dictFile;
synFR.filePath = synFile;
dictFR.openFile(dictFile);
synFR.openFile(synFile);
String[] dictionary = dictFR.fileToArray();
String[] synonyms = synFR.fileToArray();
String regx = "^[aflmptu]+$";
String regexTemplate = "^[]+$";
String word1 = "";
String word2 = "";
synToWords(synFR.getLine(3), word1, word2);//error seems to be here.
//word1 and word 2 stay ""
System.out.println(word1 +" " + word2);
printArray(findCombos(dictionary, word1, word2));
}
public static void synToWords(String syn, String wordI, String wordII){
String[] words = syn.split("\\t");
wordI = wordI + words[0];
wordII = wordII + words[1];
}
私が投稿していない他の方法がありますが、それらはすべて正常に機能しています。問題はsynToWordsメソッドだけです。どうもありがとう!