高分求解——怎么输出每个数组数都有偶数个
我的程序如下,但没显示我想输出每个数组元素出现偶数次
并求更好的方法
package Try;
public class try1 {
private String[][] st;
public try1() {
st = new String[6][6];
String[] st1 = new String[] { "我", "你", "他", "她", "她", "们" };
for (int i = 0; i < 6; i++)
for (int j = 0; j < 6; j++) {
int f = 1;// 下面while函数的判断词
java.util.Random ran = new java.util.Random();
int index = ran.nextInt(6);
st[i][j] = st1[index];
int k = (ran.nextInt(3)) + 3;
int h = ran.nextInt(6);
while (f == 1) {
if ("".equals((st[k][h]))) {
st[k][h] = st[i][j];
break;
} else {
k = (ran.nextInt(3)) + 3;
h = ran.nextInt(6);
}
}
}
}
public void print(){
for(int i=0;i<6;i++){
for(int j=0;j<6;j++)
System.out.print(st[i][j]);
System.out.println();
}
}
public static void main(String args[]){
try1 t=new try1();
t.print();
}
}