日期:2014-05-20 浏览次数:20679 次
public final static int[][] highscores = new int[3][5];
public final static String[][] players = new String[][]{
{"player", "player", "player", "player", "player"},
{"player", "player", "player", "player", "player"},
{"player", "player", "player", "player", "player"},
};
public static void addScore(int diff, String player, int score){
for(int i = 0; i < 5; i++){
if(score > highscores[diff - 3][i]){
for(int j = 4; j > i; j--){
highscores[diff - 3][j] = highscores[diff - 3][j - 1];
players[diff - 3][j] = players[diff - 3][j - 1];
}
highscores[diff - 3][i] = score;
players[diff - 3][i] = player;
break;
}
}
}
public final static int[][] highscores = new int[3][5];
public final static String[][] players = new String[][]{
{"player", "player", "player", "player", "player"},
{"player", "player", "player", "player", "player"},
{"player", "player", "player", "player", "player"},
};
public final static int[][] highscores = new int[3][5];
public void xXXX(){
int [][] A = new int[3][5] ;
...
highscores = A ; //这样子是错误的,highscores 指向的对象在内存中的地址不能改变
highscores[0][0] = 1 ;//合法 ,赋值
}