Why do we need tokens[i].equals("") continue?


  • 0
    S

    In the above code, why exactly do we need the following statements:

    if(tokens[i].equals(""))
    continue;

    I'm assuming it's something to do with the way split words because in my code, I didn't have those statements and I wasn't getting the correct answer - the extra spaces weren't getting removed.

    So I think the issue is that I'm not completely clear on how s.split(" ") works.

    Thank you for your help!


  • 0
    M

    Please check this link for the usage of split( )

    http://www.dotnetperls.com/split-java


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.