This is a simple double loop:
for(int x = 0; x < 275; x++) { final String first = arrayOfStrings[x]; for(int y = 0; y < 275; y++) { if(y == x) continue;
Edit: as comments noted, if the elements [a, b, c] have only one ab and therefore not ba , (called a combination), then the following code will work:
final ArrayList<String> collected = new ArrayList<String>(); for(int x = 0; x < 275; x++) { for(int y = 0; y < 275; y++) { if(y == x) continue;
source share