我对这个PrintWriter
有一些麻烦,它在for
循环之外工作,它确实打印"Test1"one_answers"Test2",但它不打印"示例1"在If
当我用调试器
检查时,执行这行代码。 File file = new File ("output.txt");
FileWriter wri;
try {
wri = new FileWriter(file);
PrintWriter writer = new PrintWriter(wri);
writer.println("Test1");
boolean result=false;
for(i=0;i<this.lung;i++){
for(j=0;j<this.lung;j++){
if(wordToFind.charAt(0)==mat[i][j]){
if((i>=wordLength-1)&&(results!=true))
if (wordToFind.charAt(1)==mat[i-1][j])
if(result=continue(i,j,i-1,j,1))
writer.println("example 1");
/*Same if as the above but with differente parameters are down here*/
}
}
}
}
writer.print("Test2");
writer.close();
} catch (IOException e) {
System.out.println("Error: " + e);
}
这两个results
/result
是相同的变量吗,如果是,那么尝试将第一个更改为result
;
//假设'因为我在你的代码中没有发现任何results
boolean
变量
if((i>=wordLength-1)&&(results!=true)) // results -> result
if (wordToFind.charAt(1)==mat[i-1][j])
if(result=continue(i,j,i-1,j,1))
writer.println("example 1");