arrayList Method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonathanLizama
    New Member
    • Nov 2018
    • 4

    arrayList Method

    A method that creates a total of "n: elements (all different if yes), their combinations of 1-2-3 .... n without repetition
    Example:
    Entry:
    N = {a, b, c}
    Comb.1: a | b | c
    Comb.2: ab | bc | ac
    Comb.3: abc

    this I did so far please help!


    String combine(ArrayLi st<Integer> a, String b){
    String c="";
    if(b.length()== a.size()){
    System.out.prin tln(b); //found a combo
    return "";
    }
    //append characters to string b
    for(int x=0;x<a.size(); x++){
    c=b+((Integer)a .get(x)).intVal ue();
    c+=combine(a,c) ;
    }
    return c;
    }
Working...