This code is dark magic that I don't actually understand. Why 2? Why ending the substring at "=" (if any)? Why taking a substring of a substring -- it seems like the substring calls could be combined for simplicity? -- if it helps -- if you really are purposely trying to avoid matching an '=' in the first 2 positions? -- use the optional offset argument to indexOf. 

Needs a comment along the lines of: // Expecting the input to look something like either "Z=42" or "X=42 Y=44", extract 42 as an integer.