我有一个 void 方法,它应该采用一个字符串并根据分隔符将其拆分为两个字符串。使用调试器后,该方法似乎工作正常,但是我为存储结果的方法传入的两个空字符串似乎没有得到更新。我必须在这里做一些愚蠢的事情,但感谢任何帮助!
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 方法的问题。非常感谢!