Hello, there is such a problem. Code:
String[] arr Calendar dataOfAnniversary SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); //Далее код программы в котором arr[3] присваивается дате, например "01-01-2000" . . . dateOfAnniversary = null; try { Log.d(TAG, "1 - " + arr[3]); dateOfAnniversary.setTime(sdf.parse(arr[3])); Log.d(TAG, "2"); dateOfAnniversary.add(Calendar.MONTH, 1); } catch (Exception e) { Log.e(TAG, "Exception: " + e); } Logs:
1 - 01-00-2000 Exeption: java.lang.NullPointerException Accordingly, the question: Why can not I assign a date.
PS I know that java.lang.NullPointerException says that I assign null , but if arr[3] = null , then why did the log output the date, not null ?
dateOfAnniversary. - falstaf