Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Putting characters in a String into an ArrayList

807598Jan 30 2006 — edited Jan 30 2006
I have a String that contains spaces, and I want to create an ArrayList that contains each character of the String as a single item in the list, whitespace omitted. For example, let's say I have a String as follows:
String text = "this is my text";
Then I want to go through that text letter by letter, adding each letter (either as a char or String, it doesn't matter) to an ArrayList as a separate item, and ignoring spaces.

So my ArrayList would contain 12 items: t, h, i, s, i, s, m, y, t, e, x, and t.

How can I do this? Any help or suggestions would be greatly appreciated. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2006
Added on Jan 30 2006
10 comments
495 views