title: Attempt to invoke virtual method on a null object reference error
body: <p>I'm trying to create a song object to insert into an object based array list (for a music player app). The song object should contain properties album, artist, title, etc.</p>
  
  <p>However, he app crashes when I run the program, and I get this error in the log cat.</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference
  </code></pre>
  
  <p>Here is my main class:</p>
  
  <pre><code>private ListView listView1;
  
  // A list of song objects
  private ArrayList&lt;Song&gt; songObectList;
  
  // Song object will be passed to SongObjectList
  private Song songObject = new Song();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      // Add song objects to songObjectList
      getMusic();
  
      // Initialize adapter
      SongAdapter adapter = new SongAdapter(this, R.layout.listview_item_row, songObectList);
  
      // Initialize listView
      listView1 = (ListView)findViewById(R.id.listView1);
  
      // Initialize header
      View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);
  
      // Add header to listView
      listView1.addHeaderView(header);
  
      // Add adapter to listView
      listView1.setAdapter(adapter);
  
  
  private void getMusic() {
  
      // Set URI
      Uri contentURI = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
  
      // Set projection parameter for getContentResolver query
      String[] projection = {
              MediaStore.Audio.Media.ALBUM,
              MediaStore.Audio.Media.ARTIST,
              MediaStore.Audio.Media.TITLE,
              MediaStore.Audio.Media.DATA,
              MediaStore.Audio.Media.DURATION
      };
  
      // Run getContentResolver query
      final Cursor mCursor = getContentResolver().query(
              contentURI, projection, null, null, null
      );
  
      // Set song object properties 
      if (mCursor.moveToFirst()) {
          do {
  
              songObject.album = mCursor.getString(0);
              songObject.artist = mCursor.getString(1);
              songObject.title = mCursor.getString(2);
              songObject.data = mCursor.getString(3);
              songObject.duration = mCursor.getString(4);
  
              songObectList.add(songObject);
  
          } while (mCursor.moveToNext());
      }
  
      mCursor.close();
  
      return;
  }
  </code></pre>