private void generatePermutations(
      ArrayList<HashMap<String, String[]>[]> result, int index,
      HashMap<String, String[]>[][] subResult) {
    int localIndex = index;
    HashMap<String, String[]>[] value = subResult[localIndex];
    if (localIndex == 0) {
      for (int i = 0; i < value.length; i++) {
        HashMap<String, String[]>[] resultItem = new HashMap[subResult.length];
        resultItem[localIndex] = value[i];
        result.add(resultItem);
      }
    } else {
      ArrayList<HashMap<String, String[]>[]> newResult = new ArrayList<>();
      for (int e = 0; e < result.size(); e++) {
        for (int i = 0; i < value.length; i++) {
          HashMap<String, String[]>[] resultItem = result.get(e);
          resultItem[localIndex] = value[i];
          newResult.add(resultItem);
        }
      }
      result.clear();
      result.addAll(newResult);
    }
    localIndex++;
    if (localIndex < subResult.length) {
      generatePermutations(result, localIndex, subResult);
    }
  }
private void generatePermutations ( ArrayList < HashMap < String , String [ ] > [ ] > result , int index , HashMap < String , String [ ] > [ ] [ ] subResult ) { int localIndex = index ; HashMap < String , String [ ] > [ ] value = subResult [ localIndex ] ; if ( localIndex == 0 ) { for ( int i = 0 ; i < value . length ; i ++ ) { HashMap < String , String [ ] > [ ] resultItem = new HashMap [ subResult . length ] ; resultItem [ localIndex ] = value [ i ] ; result . add ( resultItem ) ; } } else { ArrayList < HashMap < String , String [ ] > [ ] > newResult = new ArrayList < > ( ) ; for ( int e = 0 ; e < result . size ( ) ; e ++ ) { for ( int i = 0 ; i < value . length ; i ++ ) { HashMap < String , String [ ] > [ ] resultItem = result . get ( e ) ; resultItem [ localIndex ] = value [ i ] ; newResult . add ( resultItem ) ; } } result . clear ( ) ; result . addAll ( newResult ) ; } localIndex ++ ; if ( localIndex < subResult . length ) { generatePermutations ( result , localIndex , subResult ) ; } }
Generate permutations.

@param result the result
@param index the index
@param subResult the sub result