Hi, I am a beginner in Java Programming. I am working on an assignment which includes Circular shift of the words inside a string. I could find a lot of stuff about circular shift of numbers or characters but I have no idea about circular shift of complete words.
As an example,

A cup of tea
Tea a cup of
Of tea a cup
Cup of tea a

How can I implement this in Java?

Recommended Answers

All 3 Replies

Well, you will need to split the string into character array. Then you would be able to circulate each character in the array. You can use split() method of String class. The circulate part, it depends on how much knowledge you have in array... Where is your code?

Not a character array! Split gives you an array of Strings, each containing one word, which is exactly what this project needs.

Oops, String array when split I meant :P Sorry :P

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.