為什么運(yùn)行不出來(lái)啊
import java.util.Arrays;
public class HelloWorld {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? //定義一個(gè)scores數(shù)組
? ? ? ?int[] score={89 , -23 , 64 , 91 , 119 , 52 , 73};
? ? ? ?System.out.println("考試成績(jī)的前三名為:");
? ? //創(chuàng)建一個(gè)對(duì)象
? ? ? ? ?HelloWorld hello=new HelloWorld();
? ? //引用自定義對(duì)象,傳入成績(jī)數(shù)組
? ? ? ? hello.showTop3(scores);
? ? }
? ??
? ? //定義方法完成成績(jī)排序并輸出前三名的功能
? ? public void showTop3(TOP3int[] scores){
? ? ? ?Arrays.sort(scores);
? ? ? ?int num=0;
? ? ? ?for(int i=scores.length-1;i>=0;i--){
? ? ? ? if(scores[i]<0||scores[i]>100){
? ? ? ? ? ? continue;
? ? ? ? }
? ? ? ? num++;
? ? ? ? if(num>3){
? ? ? ? ? ? break;? ? ? ? ? ?
? ? ? ? }
? ? ? ? System.out.println(scores[i]);
? ? ? ?}
? ? }
}? ??
? ??
? ??
? ??
? ??
? ??
? ??
? ??
2020-07-08
? public void showTop3(TOP3int[] scores)多了個(gè)TOP3
2020-06-29
你這個(gè)報(bào)錯(cuò)顯示的意思是有多余或者缺失的“}”
2020-06-06
hello.showTop3(scores);中的scores改成score,因?yàn)槟阕约憾x的數(shù)組名為score
?? public void showTop3(TOP3int[] scores)中的TOPSint 改為int,java中沒(méi)有TOP3int這種數(shù)據(jù)類(lèi)型
檢查括號(hào)是否匹配
2020-06-01
顯示這個(gè)結(jié)果什么意思?