I have created this small program but i cant seem to make it run. It gives an error saying that intent hasnt been initialized. What should i do?

```
Spinner mySpinner1 = (Spinner) findViewById(R.id.spinner1);

    ArrayAdapter<String> myAdapter1 = new ArrayAdapter<String>(MainActivity.this,
            android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.which));
    myAdapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mySpinner1.setAdapter(myAdapter1);

    mySpinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0,
                                   View view,
                                   int position,
                                   long id) {
           Intent intent = new Intent(MainActivity.this, intent.class);
            switch (position) {
                case 1:
                    intent = new Intent(MainActivity.this, MainActivity2.class);
                    break;
            }
            startActivity(intent);
        }

```

EDIT 1 : Added few more lines of code to make the whole situation clearer