This week's book giveaways are in the Java EE and JavaScript forums. We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line! See this thread and this one for details.

Ok let`s say we have an array string like this:
String[] elements = {"a", "b", "c",...};

All I want is to generate all possible combinations (including also "aa...a","aa...b", etc).
I also run the code posted here here by Sai Narasimha Reddy but the combinations like aa, bb, .....ccb, ccc are not generated.

I tried another permutations and combinations that I found but none of them don`t generate all combinations (such as "aa...a","aa...b",...)

first, the terms 'permutations' and 'combinations' are well defined terms, and are mutually exclusive. or I guess technically, the set of combinations is a subset of permutations (unless i got that backwards).

So, before we can do much else, tell us what you really want. Combinations are where the order doesn't matter, so "ABC" is considered the same thing as "CBA".

Next...do you have to use all the elements each time? if i have 'a', 'b' and 'c', do you want 'ab', 'ac' and 'bc'? (and 'ba', 'ca and 'cb')?

finally, I'll tell you what i would tell anyone.

Before you write a single line of code, write down on paper, in english, how YOU would do this by hand, step-by-step. Then go back and revise each step, making it more and more detailed. Once you do that, writing the code is orders of magnitude easier.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

You say you want "aa...a". I take it that's virtually an infinite number of "a"s. That means that the total number of combinations is just as infinite, and it's going to be impossible to generate them all. After all, once you get "aa...a" of size X, you can get another combination by adding another "a", getting "aa...a" of size X + 1.