I have this code to check for some largest palindrome stuff (problem)
This is part of my code:
public static void main(String[] args) throws IOException {
BufferedWriter out = new BufferedWriter(new FileWriter("./out"));
for(int i=999;i>0;i--)
{
for(int j=999;j>0;j--)
{
if(isPalu(i*j))
{
int o=i*j;
out.write(String.valueOf(o));//not working
System.out.println(o);
return;
}
}
}
// out.write(String.valueOf(5*5)); //writes 25 fine!
out.close();
}
The ridiculous problem here is the BufferedWriter out
is working outside the for loop (commented 2nd last line) and is writing to file ./out
. But not inside nested loop. (I get empty file) On the other hand the println
inside loop is working fine!
Also my vscode debugger is suggesting to close the out
when I still having the last line for close.