Multiple choice technology programming languages

What is the result of compiling and running the following program? import java.util.Arrays; class Split2 { public static void main(String[] args) { String str = "She sells sea shells"; System.out.println(Arrays.toString(str.split("\s"))); } }

  1. Compiler error

  2. An exception is thrown at runtime

  3. Prints [She, sells, sea, shells]

  4. Prints [he, ells, ea, hells]

  5. Prints []

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The split("\\s") method splits the string around matches of the regular expression \s (whitespace). This correctly splits "She sells sea shells" into an array of four words, which Arrays.toString() prints as [She, sells, sea, shells].