I think if(pCode[orderNum] == "M3487") is the if statement you are talking about.
The reason is pCode[0] - pCode[n] has a value of "null" (String "null" not null pointer).
why? because you never...