java入門第一季中,7-6的練習(xí)怎么寫代碼?。空埓笊駧蛶兔?!
3 回答
已采納

望遠(yuǎn)
TA貢獻(xiàn)1017條經(jīng)驗(yàn) 獲得超1032個贊
import?java.util.Arrays; public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ HelloWorld?hello?=?new?HelloWorld(); int[]?scores={79,52,98,81}; ???????? //調(diào)用方法,傳入成績數(shù)組,并獲取成績的個數(shù) int?count=hello.sort(scores); 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)); return?scores.length; ????????//返回數(shù)組中元素的個數(shù) ???????? } }
點(diǎn)擊展開后面7條
添加回答
舉報
0/150
提交
取消