第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

package com.HelloWorld; import java.util.Arrays; public class HelloWorld { //完成 main 方法 public static void main(String[] args) { HelloWorld hello=new HelloWorld(); hello.sort(89 , -23 , 64 , 91 , 119

package?com.HelloWorld;
import?java.util.Arrays;
public?class?HelloWorld?{
????
????	?//完成?main?方法
????????public?static?void?main(String[]?args)?{
????????????HelloWorld?hello=new?HelloWorld();
????????????
????????????hello.sort(89?,?-23?,?64?,?91?,?119?,?52?,?73);
????????????
????????}
????????
????????//定義方法完成成績排序并輸出前三名的功能
????????public?void?sort(int?scores[]){
????????	Arrays.sort(scores);
????????	for(int?i=0;i<2;i++){
????????		System.out.println(scores[i]);
????????		if(scores[i]>100){
????????????		System.out.println("輸入無效");
????????????	}else?if(scores[i]<0){
????????????		System.out.println("輸入無效");
????????????	}
????????	}
????????	
????????	
????????}
????????這個在調(diào)試sort()的時候顯示紅色,為什么會不行呢?

正在回答

8 回答

package?com.HelloWorld;
import?java.util.Arrays;
public?class?HelloWorld?{
????
????	?//完成?main?方法
????????public?static?void?main(String[]?args)?{
???????????int?scores[]={89,-23,64,91,119,52,73};
????????HelloWorld?hello?=new?HelloWorld();
???????
????????System.out.println("前三名的成績?yōu)椋?);
????????hello.show(scores);
????????}
????????
????????public?void?show(int?[]scores){
????????	Arrays.sort(scores);
????????	int?num=0;
????????	for(int?i=scores.length-1;num<3;i--){
????????		if(scores[i]>100^scores[i]<0){
????????		continue;
????????	}
????????		num++;
????????		System.out.println(scores[i]);
????????		
????????		}

??????
????}
}

我把System.out.pringtln("前三名的成績?yōu)椋?+hello.show());

變成

System.out.println("前三名的成績?yōu)椋?);
? ? ? ?hello.show(scores);

就可以了,為什么呢?

0 回復(fù) 有任何疑惑可以回復(fù)我~

System.out.pringtln("前三名的成績?yōu)椋?+hello.show());這個是你打的

0 回復(fù) 有任何疑惑可以回復(fù)我~

public class HelloWorld {
??? ?
???????? //完成 main 方法
??????? public static void main(String[] args) {
?????????? ?
?????????? int []scores={89,-23,64,91,119,52,73};
????????? ?
??????? HelloWorld hello =new HelloWorld();
?????? ?
?????? ?
??????? System.out.println("前三名的成績?yōu)椋?);
??????? hello.show(scores);
??????? }
??????? ?
??????? public void show(int []scores){
?????????? ?
??????????? Arrays.sort(scores);
?????????? ?
??????????? int num=0;
?????????? ?
??????????? for(int i=scores.length - 1;num<=3;i--){
?????????????? ?
??????????????? if(scores[i]>100 || scores[i]<0){
?????????????????? ?
??????????????? continue;
??????????? }
??????????????? num++;
?????????????? ?
??????????????? System.out.println(scores[i]);
??????????????? ?
?????????????? }
??? }
你那個show方法不能寫在println里面(你這都打錯真是無語),并且這個方法是有參數(shù)的,你的參數(shù)呢,先把前面幾章再認(rèn)真看看吧

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Irays

就是啊
2015-12-09 回復(fù) 有任何疑惑可以回復(fù)我~

其實(shí)我寫的與題目偏了,這個程序表達(dá)的是 輸入89 , -23 , 64 , 91 , 119 , 52 , 73

然后自動輸出前三名。但是我也想知道這樣的程序應(yīng)該怎么弄。

我更改之后還是不行。

package?com.HelloWorld;
import?java.util.Arrays;
public?class?HelloWorld?{
????
????	?//完成?main?方法
????????public?static?void?main(String[]?args)?{
???????????int?scores[]={89,-23,64,91,119,52,73};
????????HelloWorld?hello?=new?HelloWorld();
????????hello.show(scores);
????????System.out.pringtln("前三名的成績?yōu)椋?+hello.show());
????????}
????????
????????public?void?show(int?[]scores){
????????	Arrays.sort(scores);
????????	int?num=0;
????????	for(int?i=scores.length;num<=3;i--){
????????		if(scores[i]>100^scores[i]<0){
????????		continue;
????????	}
????????		num++;
????????		System.out.print(scores[i]);
????????		
????????		}

??????
????}
}


0 回復(fù) 有任何疑惑可以回復(fù)我~

public class HelloWorld {
??? ?
???????? //完成 main 方法
??????? public static void main(String[] args) {
?????????? ?
??????????? HelloWorld hello = new HelloWorld();
?????????? ?
???????????? int []scores = {89 , -23 , 64 , 91 , 119 , 52 , 73};
??????????? ?
??????????? hello.sort(scores);
?????????? ?
??????? }
???????????? //定義方法完成成績排序并輸出前三名的功能
??????? public void sort(int []scores){
?????????? ?
??????????? Arrays.sort(scores);
??????????? int num = 0;
?????????? ?
??????????? 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]);
??????????? }??
??????? }

你那個有好幾個問題啊,改起來好麻煩,你先看看這個,不懂再說

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

這個小鋒 提問者

沒看懂我錯在哪里,能否麻煩分點(diǎn)列出來呢?
2015-12-08 回復(fù) 有任何疑惑可以回復(fù)我~

顯示紅色好像是代表sort是JAVA關(guān)鍵字吧 ?關(guān)鍵字不能拿來定義方法名

0 回復(fù) 有任何疑惑可以回復(fù)我~

public?void?sort(int?scores[])應(yīng)該是public?void?sort(int[]?scores)

hello.sort(89?,?-23?,?64?,?91?,?119?,?52?,?73);

應(yīng)該是int[] scores={89?,?-23?,?64?,?91?,?119?,?52?,?73};

hello.sort(scores);

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

這個小鋒 提問者

其實(shí)我寫的與題目偏了,這個程序表達(dá)的是 輸入89 , -23 , 64 , 91 , 119 , 52 , 73 然后自動輸出前三名。但是我也想知道這樣的程序應(yīng)該怎么弄。 我更改之后還是不行。
2015-12-08 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

package com.HelloWorld; import java.util.Arrays; public class HelloWorld { //完成 main 方法 public static void main(String[] args) { HelloWorld hello=new HelloWorld(); hello.sort(89 , -23 , 64 , 91 , 119

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號