-
How do I get a reverse order from the String Tokenizer?
I am working on a Java Assignment in school. We are dealing with the String
tokenier. I need to find a command that will aloow me to tokeinze a string
from user input and reverese the order of the words
Any suggestion would be apprecated.
Brad Clark
-
Re: How do I get a reverse order from the String Tokenizer?
Here's a hint: you won't be able to output the words in reverse order until
you have read them all in.
Brad Clark <Clar0135@algonquincollege.com> wrote in message
news:396da134$1@news.devx.com...
>
> I am working on a Java Assignment in school. We are dealing with the
String
> tokenier. I need to find a command that will aloow me to tokeinze a string
> from user input and reverese the order of the words
>
> Any suggestion would be apprecated.
>
> Brad Clark
-
Re: How do I get a reverse order from the String Tokenizer?
Here is a slightly unorthadox method to make you think about how to approach
the solution. You can work out how to get the user input yourself.
Regards
John Timney (MVP)
import java.util.*;
public class string {
public static void main(String args[]){
StringBuffer myStringBuffer = new StringBuffer("which token comes first");
StringTokenizer st = new
StringTokenizer(myStringBuffer.reverse().toString(), " ");
while(st.hasMoreTokens()){
StringBuffer s= new StringBuffer(st.nextToken());
System.out.println(s.reverse());
}
}
}
Paul Clapham <pclapham@core-mark.com> wrote in message
news:396dd89a@news.devx.com...
> Here's a hint: you won't be able to output the words in reverse order
until
> you have read them all in.
>
> Brad Clark <Clar0135@algonquincollege.com> wrote in message
> news:396da134$1@news.devx.com...
> >
> > I am working on a Java Assignment in school. We are dealing with the
> String
> > tokenier. I need to find a command that will aloow me to tokeinze a
string
> > from user input and reverese the order of the words
> >
> > Any suggestion would be apprecated.
> >
> > Brad Clark
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks