Hi, I was wonder if someone could give me some help with my program
I have a variable:
"playing football"
and i want to split that into chars like so, 'playing', 'football'

can you help me???

Recommended Answers

All 5 Replies

There are several ways to do this. Some of them are part of the String class - see the Sun website for those.

If you want to do it by hand, we can walk you through the way you'd go about it.

chars like so, 'playing', 'football'

chars are primitives representing a single character. What you show is a String inside of single quotes which is not legal syntax in java.
A char literal would be: 'p' or 'f'
"playing" is a String

The StringTokenizer in java.util.* may do your job.

Use the spilt method (which goes into a string array) so string.split(" ")...that should do it

You see, there's a ton of ways to do what you want to do. What exactly do you want to do?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.