一只甜嘎
2017-06-13 19:48
package program;
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
int scores[]={89,-23,64,91,119,52,73};
HelloWorld target = new HelloWorld();
System.out.println("考试成绩的前三名为:"+ArrayType.toString(target.sort(scores)));
}
public void sort(int []scores){
Arrays.sort(scores);
int count =0;
for(int i = scores.length;i>=0;i--){
while(count<3){
if(scores[i]>=0 || scores[i]<=100){
continue;
}
System.out.println(scores[i]);
count+=1;
}
}
}
}
package program;
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
int scores[]={89,-23,64,91,119,52,73};
HelloWorld target = new HelloWorld();
System.out.println("考试成绩的前三名为:"+ArrayType.toString(target.sort(scores)));
target.sort(scores); //这里少了一这样一句,否则scores[]的值将无法传递
}
public void sort(int []scores){
Arrays.sort(scores);
int count =0;
for(int i = scores.length;i>=0;i--){
while(count<3){
if(scores[i]>=0 || scores[i]<=100){
continue;
}
System.out.println(scores[i]);
count+=1;
}
}
}
}
没有进行方法调用,参数无法传递
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题