Why it throwing java.lang.nullpointerexception attempt to invoke virtual method 'int java.lang.string.length()'