Are you asking how to determine mathematically the number of different combinations of letters, given a particular string? I may very well be wrong, but isn't it the number of characters factorial? Say you had 5 characters, 5! equals 120. There are 120 different possible ways to rearrange the characters. Or take the sequence "123". 3 characters, so 3! equals 6: 123 132 213 231 312 321 Please correct me if I'm mistaken.
If you are asking how to make an algorithm to rearrange the characters in a string I'm sure we'd be able to help you. If that's more like what you're asking, are you looking for any combinations, or do you want to find ones that are actual words? For that you'd probably compare each new string to a dictionary (or word list) to test if it's actually a word. [ April 03, 2007: Message edited by: Eric Daly ]
it's more complicated than a factorial if you can have a repeated letter. (h) (e) (l-one) (l-two) (o) is the same as (h) (e) (l-two) (l-one) (o). You can still use the factorial to get an idea, but the actual number is less, depending on how many letters are repeated, and how many times each letter is repeated.
A good book on discrete math should help you figure it out, if you need to know the exact number, but you may not care.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
The solution to your question lies in implementing an algorithm on "generating anagrams" that you can implement within your Java code. A discussion on algorithms for generating anagrams is too complex and beyond the scope of this forum.
But books/articles written by gurus such as Jon Bentley or Knuth would give you an idea in this direction.
Once you've clarified exactly what you want to do, I suggest carefully describing your approach (algorithm) in English first. Once this is done, use your written description to write the Java code. This will help prevent going down the wrong path and missing important details in your code.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org