This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Generate mixed cases of a word Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generate mixed cases of a word" Watch "Generate mixed cases of a word" New topic

Generate mixed cases of a word

Chethan Sharma
Ranch Hand

Joined: Mar 22, 2006
Posts: 59

How do I generate different cominations/ mixed cases of a word.

Eg: Test

Please let me know .


Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37884
Have you tried changing your String to a char[] array and using the toLowerCase and toUpperCase methods of Character?
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
You could loop through the string, then for each character, you use a random generator to determine 1 or 0, then invoke the toLowerCase or toUpperCase method.

SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
It is sorta covered in the JavaRanch Style Guide.
subject: Generate mixed cases of a word
Similar Threads
generate data population source code for junit?
test case for servlets
eclipse and junit - how to generate report?
Why can't I code?
Dependency Inversion Principle