So I want to split a String
into strings, for example I have a String
"Hello! I am trying to lea?!!rn java" and I want to have Strings like
"Hello","I","am","trying","to","learn" and "java", what's the best way to do it?
Asked
Active
Viewed 100 times
-1

Jaime
- 21
- 3
-
2Is your string supposed to have `?!!` in the middle of it, or is that a typo? – khelwood Jun 12 '18 at 14:54
-
consider looking here https://stackoverflow.com/questions/225337/how-do-i-split-a-string-with-any-whitespace-chars-as-delimiters?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Ben Sch Jun 12 '18 at 14:55
-
This might be a duplicate of Maciej's link, and it might be a duplicate of Berger's link, or it might be a unique combination of the two which means it's not a duplicate. Regardless, Jaime, you really should show us the code you've used, what its output is, and why you feel that output is different from what you want it to do. That's going to give you the best results here. – corsiKa Jun 12 '18 at 15:00
1 Answers
3
Use:
String string = "Hello! I am trying to learn java";
String[] parts = string.split(" ");
And tell your teacher where you got the answer from.

user1156544
- 1,725
- 2
- 25
- 51