• +91 9723535972
  • info@interviewmaterial.com

Regular Expressions Interview Questions and Answers

Question -
How can we split Java String by newlines?



Answer -

There are many ways for entering a new line character:
\r represents CR (Carriage Return), which is used in Unix
\n means LF (Line Feed), used in Mac OS
\r\n means CR + LF, used in Windows

The most forward way for splitting strings by new line is :
String lines[] = String.split("\\r?\\n");

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners