为什么调用方法时方法名会报错,好几次遇到这个问题了,麻烦大家指点一下!报错在倒数第二排~谢谢~~~
package com.AL;
import java.util.Arrays;
import java.util.Scanner;
import java.math.*;
public class method {
public int[] getScores(int length){
Scanner input = new Scanner(System.in);
System.out.print("Please input how many scores we have : ");
length = input.nextInt();
int[] scores = new int[length];
int count = 0;
for(int i=0;i<scores.length;i++){
System.out.print("Please input num"+(i+1)+"'s score: ");
scores[i]=input.nextInt();
if(scores[i]<0||scores[i]>100){
scores[i]=0;
continue;}
count++;
}
System.out.println("We have "+count+ " avilable scores");
Arrays.sort(scores);
for(int best=length-1;best>0;best--)
{
if(scores[best]<0||scores[best]>100)
if(count>=3)
// for(int h=(length-1);h>(length-4);h--) {
// }
break;}
System.out.println("The best 1 is "+scores[length-1]);
System.out.println("The best 2 is "+scores[length-2]);
System.out.println("The best 3 is "+scores[length-3]);
return scores;
}
public static void main(String[] args) {
method best3 = new method();
Scanner input = new Scanner(System.in);
int[] scores = best3.getScores(scores);
System.out.println(Arrays.toString(scores));
}
}