How to generate multiple nested repeat structures with methods

Asked

Viewed 123 times

0

need to generate several nested structures (26) wanted to know how to do this with methods pro code not get too big an example of the structure I need with 4 nested:

public static void main(String[] args) {
    String[] vet={"1","2","3","4"};
    for(int i=0;i<4;i++)
        for(int j=0;j<4;j++) if(i!=j)
            for(int k=0;k<4;k++) if(j!=k && i!=k)
                for(int l=0;l<4;l++) if(k!=l && i!=l && j!=l)
                    System.out.println(vet[i]+vet[j]+vet[k]+vet[l]);

}
  • 1

    Out of curiosity, what is your need to need 26 for nested?

  • 1

    I would also like to know what makes it necessary to have 26 ties, surely there must be better ways to do this.

  • Just to reinforce what has already been said 26 nested structures is no solution to any problem. Rethink the problem, and follow a viable path, other than this.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.