方法不一定需要返回值吧 我這里哪里錯了哦
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};
? ? ? ? int count=0;
? ? ? ? hello.ranks(scores);
? ? ? ? public void ranks(int[] ranks){
? ? ? ? ? ? int[] ranks1=Arrays.sort(ranks);
? ? ? ? ? ? outer:
? ? ? ? ? ? for(int i =ranks1.length-1;i>=0;i--){
? ? ? ? ? ? ? ? if(ranks[i]<0|| ranks[i]>100){
? ? ? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? count++;
? ? ? ? ? ? ? ? System.out.println("考試的前三名為:");
? ? ? ? ? ? ? ? System.out.println(ranks1[i]);
? ? ? ? ? ? ? ? if(count>3){
? ? ? ? ? ? ? ? ? ? break outer;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ??
? ? }
? ??
2017-06-04
改了下 ranks方法 正常了
2017-05-23
括號的問題,你看下你的main方法的最后一個大括號在哪?
2017-05-22
no one can help me?
2017-05-21
public class HelloWorld{
//完成 main 方法
public static void main(String[] args) {
? ? ? ?HelloWorld hello= new HelloWorld();
? ? ? ?int[] scores={89,-23,64,91,119,52,73};
? ? ? ?hello.ranks(scores);
}
? ? ? ?public void ranks(int[] ranks){
? ? ? ?int count=0;
? ? ? ? ? ?Arrays.sort(ranks);
? ? ? ? ? ? ? ? System.out.println("考試的前三名為:");
? ? ? ? ? ?for(int i =ranks.length-1;i>=0;i--){
? ? ? ? ? ? ? ?if(ranks[i]<0|| ranks[i]>100){
? ? ? ? ? ? ? ? ? ?continue;
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?count++;
? ? ? ? ? ? ? ?System.out.println(ranks[i]);
? ? ? ? ? ? ? ?if(count>=3){
? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?}
}