無(wú)返回值的方法我的代碼可以跑,可我想做一個(gè)帶返回值類型為數(shù)組類型的,就不行,求教是為什么?代碼如下
import java.util.Arrays;
public class HelloWorld {
???
??? //完成 main 方法
??? public static void main(String[] args) {
??????? HelloWorld hello = new HelloWorld();
??????? int [] Scores = {89,-23,64,91,119,52,73};
??????? System.out.println("考試成績(jī)的前三名為:");
??????? hello.output(Scores);?
??? }
???
??? //定義方法完成成績(jī)排序并輸出前三名的功能
??? public int[] output(int Scores[]){
??????? int num = 0;
?????? Arrays.sort(Scores);
?????? for(int i=Scores.length-1;i>=0;i--){
?????????? if(Scores[i]>100||Scores[i]<0){
?????????????? continue;
?????????? }
?????????? num++;
?????? if(num>3){
?????????? break;
??????? }
?????? System.out.println(Scores[i]);
?????? }
??? }
??? return Scores[];
}
2019-07-04
return Scores;
2019-06-20