Java初学篇
2018.11.8
初学篇1
今天学了挺多的,学了像if else语句以及switch语句。学了,我也开始练了一遍,还是有很多的单词不是很熟悉。
要争取多练几遍,多看看教程,看看别人打的时候是怎么想的,思路是咋样的。
class Demo1{
public static void main (String[] args){
int year = 2020;
int month = 2;
int day = -1;
switch (month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31;
break;
case 4:
case 6:
case 9:
case 11:
day = 30;
break;
case 2:
if(year % 400 == 0 || (year % 4 == 0 && year % 100 !=0 )){
day = 29;
}else{
day = 28;
}
break;
default:
System.out.println("月份不合理");
break;
}
if (day != -1){
System.out.println(year + "年" + month + "月有" + day + "天");
}
}
}
所以今天,在Java中又学了挺多东西的,还要单词。
public static void main (String [] args) {
}
case
if else
default
System.out.println
break