LearnFrenzy
Sign in Take a free test

Strings and StringBuilder · Java Strings MCQ · Question 7

Splitting on a dot Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 7 Back to Exercise

How do you split "192.168.1.1" into its four numbers?

  • A s.split(".")
  • B s.split("\\.") Correct
  • C s.split('.')
  • D s.split(" . ")
Correct Answer: Option B

split takes a regex, in which . matches any character; "\\." in Java source is the regex \. (a literal dot).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links