It's not unreachable code you numpty. That's the worst definition ever.
This is unreachable code.
function doSomething( int x )
{
if (x == 1)
return 1;
else
return 0;
return 0; // << unreachable, never ever in a million years will this get executed.
}
His print statement gets executed, which means it's not unreachable code.
This is more like what he should be doing:
for (int i=0; i < numberArray.length; i++) // Loop through all of the array elements
{
if ( (numberArray[i] % 2) == 0) // if the current element is divisible by two and has no remainder (an even number)
{
if (numberArray[i] < 412) // if the number is less than 412
{
print numberArray[i]; // print it out
}
}
}
This can also be optimized further by performing the modulo check at the same time as the number size by using an AND operator
for (int i=0; i < numberArray.length; i++) // Loop through all of the array elements
{
if ( ((numberArray[i] % 2) == 0) && numberArray[i] < 412 ) // if the current element is divisible by two and has no remainder
{ // (an even number) AND (&&) is less than 412
print numberArray[i]; // print it out
}
}