嗨,我试图格式化并创建此数组:阵列格式化方法
Person[] persons = { person1, person2, person3, person4, person5, person6, person7, person8, person9, person10 };
// The aim is to form an array of the 5 strongest people's indices above
int[] arrayOfStrongestPeopleIndices = new int[5];
for (int index = 0; index < 10; index++){
int strength = persons[index].strength;
for (int str : arrayOfStrongestPeopleIndices){
//something @ here ?
}
}
所以我到10人试图循环,以及阵列arrayOfStrongestPeopleIndices
应该是最强的人指数为5(以最强为了最弱的,即array[0]
是最强的人指数开出5,而array[4]
是最弱的5)
的问题:我如何返回格式化arrayOfStrongestPeopleIndices的规定?
请张贴可执行代码,因为人员数组大小我们无法猜测。 – RamPrakash
你对这篇文章有任何问题吗? –
编辑过的主帖,应该比较容易看懂 –