慕數(shù)據(jù)6005589
2018-06-21 22:20:26
import java.util.Arrays;public class HelloWorld {??? public static void main(String[] args) {?? ??? ?HelloWorld hello = new HelloWorld();?? ??? ?//調(diào)用方法,傳入成績數(shù)組,并獲取成績的個數(shù)?? ??? ?int count=hello.sort(int scores={79,52,98,81});?? ??? ?System.out.println("共有"+count+"個成績信息!");?? ?}?? ?/*?? ? * 功能:將考試成績排序并輸出,返回成績的個數(shù)?? ? * 定義一個包含整型數(shù)組參數(shù)的方法,傳入成績數(shù)組?? ? * 使用Arrays類對成績數(shù)組進(jìn)行排序并輸出?? ? * 方法執(zhí)行后返回數(shù)組中元素的個數(shù)?? ? */?? ?public int sort(int[] scores?????????? ){?? ??? ?Arrays.sort(scores);?? ??? ?System.out.println(Arrays.toString(scores));??????? //返回數(shù)組中元素的個數(shù)??????? return scores.length;?? ?}}加粗斜體的那一行是不是不能這么寫
添加回答
舉報
0/150
提交
取消