虽然月份是随机的,但天数都是对应的啊,为什么同样是1月,再运行天数会不同呢?

import java.util.Random;

public class Exercise7_2 {

public static void main(String[] args)
{
    // TODO Auto-generated method stub
    Exercise7_2 e=new Exercise7_2();
    System.out.println(e.getMonth()+"月共有"+e.getNumOfDays(e.getMonth())+"天。");

}

int getMonth()
{
    Random r=new Random();
    int month=r.nextInt(12)+1;
    return month;
}

int getNumOfDays(int month)
{
    int num;
    if(month==2) num=28;
    else if(month<=7&&month%2==1||month>7&&month%2==0) num=31;
    else num=30;
    return num;
}

}

System.out.println(e.getMonth()+"月共有"+e.getNumOfDays(e.getMonth())+"天。");

--因为e.getMonth()是随机月份,所以此行代码中两次调用,很大概率返回不通的月份

int getNumOfDays(int month)
{
int num;
if(month==2) {
num=28;
}else if(month<=7&&month%2==1||month>7&&month%2==0){

    num=31;
    }else {
    num=30;
}
return num;

}