这样貌似可以,还可以改变数组的大小-
- public static void method1(){
- String[] pa=new String[]{"a","b","c","d"};
- StringBuilder s=new StringBuilder();
- int count=pa.length;
- for(int i=0;i<(int)(Math.pow(count,count));i++){
- int n=i;
- for(int k=0;k<count;k++){
- s.append(pa[n%count]);
- n/=count;
- }
- System.out.println(s.toString()+"---"+i);
- s=new StringBuilder();
- }
- }
复制代码 |