根据给定的字符和长度生成所有可能的组合(单词列表)

Generate all possible combinations from given characters and length (wordlist)

我有一个像“abc”这样的字符串。

现在我想得到这些字符的所有可能组合:\

“aaa”
“aab”
“aac”
“阿巴”
...
“ccc”

如何在 java 中执行此操作?

这只是一个伪代码,不是 java。

char = {a,b,c} 
l = 3

for(i = 0;i<l;i++)
 for(j = 0;j<l;j++)
   for(k = 0;k<l;k++)
     print(char[i],char[j],char[k],"\n")
   end for
 end for
end for

如果有,请分享 works/not/understandable。