So I'm basically finished with a program, and at the end of it I'm printing Strings from an array to a file. The array may contain null values, so I'm checking for null before I print, but I keep ending up with 1 null at the very end of the file...
Here's the code I'm using to check for null
for(int i=0;i<array2.length;i++)
{
if(array2[i] != null)
out.println(array2[i]);
}
I know that the array contains multiple instances of null, but only 1 is being printed. I tried using the debugger and when array2[i] == null, it still entered the conditional statement...
So I added a println statement to help me see what's going on. It now looks like this:
for(int i=0;i<array2.length;i++)
{
if(array2[i] != null)
{
System.out.println("Adding " + array2[i]);
out.println(array2[i]);
}
Just after printing all the String values to the console, it prints "Adding null" so I know it's happening here in this if statement. Why is this happening???
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)