forum

Home / DeveloperSection / Forums / How to split a string in java?

How to split a string in java?

Anonymous User191210-Oct-2014
I have a string "004-034556" that I want to split into two strings:
String str1 = "004";
String str2 = "034556";

That means the first string will contain the characters before '-', and the second string will contain the characters after '-'. I also want to check if the string has '-' in it. If not, I will throw an exception. How can I do this?



Updated on 10-Oct-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By