for (int i = 0; i < arr.length; i++) {
for (int a = 0; a < book.length; a++) {
if (book[a].equalsIgnoreCase(arr[i])) {
//IF I TRY TO PRINT ARR[I] HERE IT HAS A VALUE
bi = 1;
}
}
if (bi != 1) {
dif[l] = arr[i];
//HERE ARR[I] IS NULL
System.out.println(arr[i]);
l = l + 1;
}
}
You never reset the value of bi, so as soon as there is one entry in arr that is equal to one entry in book all subsequent values in arr will be outputted which might include null.
1
solved value of array changes for no reason JAVA