I have a string array = String[] str = {"a","b","c","d"} that I want o multiply with itself thrice to get triplets in this form = {a,b,c}..and so on.
I wrote this code:
String[] str = {"a","b","c","d"};
for(int i=0; i<str.length;i++){
for(int j=1;j<str.length;j++){
for(int k=2; k<str.length;k++){
System.out.println(str[i]+"_"+str[j]+"_"+str[k]);
}
}
}
But the output I get looks like this:
a_b_c
a_b_d
a_c_c
a_c_d
a_d_c
a_d_d
b_b_c
b_b_d
I want only unique combinations: a_b_c, a_b_d, a_c_d, b_c_d
Can I get some help here please?