import java.util.Arrays;
/**
* 数组用for进行遍历。
*/
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
public class Z202 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int scores[]={73,25,43,89,46,69};
Arrays.sort(scores);//对数组进行快排。
//下方遍历,是从scores数组第一个遍历到最后一个,将值赋给score
for(int score:scores){//第一个定义一个变量,第二个是要遍历的数组
//定义的变量必须和遍历的数组类型一致。
System.out.println(score);
}
}
}
数组用for遍历,for(int score:scores)
最新推荐文章于 2023-06-03 22:41:23 发布