public class MainActivity extends Activity { private TextView mDateDisplay; private ImageButton mPickDate; private int mYear; private int mMonth; private int mDay; static final int DATE_DIALOG_ID = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDateDisplay = (TextView)findViewById(R.id.DataStart); mPickDate = (ImageButton)findViewById(R.id.showDatePicker); mPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(DATE_DIALOG_ID); } }); final Calendar c = new Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH); mDay = c.get(Calendar.DAY_OF_MONTH); updateDisplay(); } 

Here is the error log:

 Error:(37, 38) error: cannot find symbol class getInstance 

At the same time, this method knocks out in auto-complete. PS I apologize for the stupid question, as a newcomer to this business.

    1 answer 1

    You initialize the class new Calendar from here and an error;

     final Calendar c = new Calendar.getInstance(); 

    delete new and you will succeed. (PS when you want to call a static method of any class, you do not need to initialize it with new )

      final Calendar c = Calendar.getInstance();