public void decompressTo(String fileName) throws IOException {
for (int i = 0; i < fileArray.size(); i++) {
if (fileArray.get(i) == new Character((char) 7)) {
//do stuff
}
else {
//do other stuff
}
}
The problem is that my if statement is never being executed, instead, the for loop always jumps to the else statement.
However, the fileArray ArrayList that I am reading from for sure contains the bell character (ASCII Character #7). I have declared fileArray as follows: ArrayList <Character> fileArray = new ArrayList <Character> ();.
Creating
new Character((char) 7))seems unnecessary object creation. HenceTry this. Make suere your
fileArray.get(i)is not null.