Sunday, 15 September 2013

Java split() checking if index equals a value -


I have a function that gets passed in the string I

  string [] The strings are split with info = s.split ("\\ s +");   

I want to see that the first index is plus sign (+). If I enter in a string: + Other stuff claims that +! {+++> "info = 0 ++ +" = ""); if (info [0] == "+") {System.out .println ("yes");} Else System.out.println ("no");

This is the output I received:

  Interp & Anybody know why this is?   

< When comparing code> string s, always use String.equals (string str) . == Comparison of wire for equal memory recognition, String.equals () will compare for similar content.

if (info [0] Equals ("+") {Do stuff ..}

No comments:

Post a Comment