← Quiz: Java Strings: all 10 questions
Quiz: Java Strings · Question 9 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
System.out.println("a,b,,c,,".split(",").length);
}
}
- A.4
- B.6
- C.3
- D.5
Answer & explanation
Correct answer: 4
split keeps the empty string between the two middle commas (a, b, "", c) but drops empty strings at the end.
Can you get the rest right without peeking?
Take the timed Quiz: Java Strings quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →