-2

I tried initializing like a regular array of primitive objects.

public class AnotherActivity extends AppCompatActivity{

    public Spinner [] jobSites;
    Spinner x, y;

    @Override
    protected void OnCreate(Bundle savedInstanceState){

         x= findViewById(R.id.job1);
         y= findViewById(R.id.job2);
         jobSites = {x,y};
    }
Danny
  • 39
  • 9
Hector
  • 150
  • 1
  • 13

1 Answers1

1

Change line jobSites = {x,y}; to jobSites = new Spinner[]{x,y}. Here you jobSites acts as reference to array which is null initially. Without creating an array you are trying to jobSites refer something...

Kindly learn basics of array initialization in java. This post might help you.

Shadow Droid
  • 1,696
  • 1
  • 12
  • 26