AndroidStudio Calendar.get(Calendar.DAY_OF_MONTH) nullPointer Exception

前端 未结 4 1395
傲寒
傲寒 2020-12-22 06:10

I have a problem with my calendar. Here is the code:

Calendar mCalendar = Calendar.getInstance();
mToday[0] = mCalendar.get(Calendar.DAY_OF_MONTH);
mToday[1]         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 06:50

    I do believe that the way you access the calendar is correct.

    I'm guessing the int[] you try to add the values to is not initialized. You must call

    int[] mToday = new int[3];
    

提交回复
热议问题