fosho fosho - 10 months ago 34
Java Question

Split string into individual words Java

I would like to know how to split up a large string into a series of smaller strings or words.
For example:

I want to walk my dog.

I want to have a string:
another string:
, etc.

How would I do this?


Use split() method


String s = "I want to walk my dog";

 String[] arr = s.split(" ");    

 for ( String ss : arr) {