已采納回答 / lolmbp
可以,但不建議。例如平均值,兩者均能正常編譯運行,但后者更規(guī)范double pingJunZhi;????????// baddouble avg;????// good
2021-07-02
最贊回答 / qq_慕數(shù)據(jù)7542031
default的位置對執(zhí)行結(jié)果沒有影響。關(guān)鍵看default有沒有使用break,使用了break會跳出,不使用break會執(zhí)行剩下的代碼。
2021-07-02
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
int i,j;
count=num;
for(i=0;i<9;i++){
count=count/10;
if(count==0){
System.out.println("它是個"+(i+1)+"位的數(shù)!");
break;
}
}
}
}
public static void main(String[] args){
int num = 999;
int count = 0;
int i,j;
count=num;
for(i=0;i<9;i++){
count=count/10;
if(count==0){
System.out.println("它是個"+(i+1)+"位的數(shù)!");
break;
}
}
}
}
2021-06-30
int zhou = new Scanner(System.in).nextInt();
if(zhou>0&&zhou<=35){
for(int yue=zhou-zhou%4;yue<contentList.length&&yue<zhou+3;yue++){
if(zhou-1==yue){
System.out.print("√");
}
System.out.println(contentList[yue]);
}
}else System.out.println("您輸入的周暫時沒有計劃");
這個夠簡略吧
if(zhou>0&&zhou<=35){
for(int yue=zhou-zhou%4;yue<contentList.length&&yue<zhou+3;yue++){
if(zhou-1==yue){
System.out.print("√");
}
System.out.println(contentList[yue]);
}
}else System.out.println("您輸入的周暫時沒有計劃");
這個夠簡略吧
2021-06-28