title: Simple java music database with NullPointerException
body: <p>I'm first year computer science and our assignment for semester 1 is to design a simple music database in java. 
  I'm using 3 classes, Interface(handles all user in/out), Song(stores artist, name, duration and filesize) and Database(stores 4 song objects; a,b,c,d). I can compile and run the the program fine, but when I enter the last field(fileSize) instead of a message returning the recently entered information I receive a NullPointerException, I understand this has something to do with assigning the value of null. </p>
  
  <p>The code for the database class is;</p>
  
  <pre><code>public class songDatabase
  {
      song sin = new song();
      private song a,b,c,d;
  
      public songDatabase()
      {
          a = null;
          b = null;
          c = null;
          d = null;
      }
  
      public void addSong(String artist, String name, double duration, int fileSize)
      {
          if (a==null) setData(a,artist,name,duration,fileSize);
          else if (b==null) setData(b,artist,name,duration,fileSize);
          else if (c==null) setData(c,artist,name,duration,fileSize);
          else if (d==null) setData(d,artist,name,duration,fileSize);
      }
  
      private void setData(song sin, String artist, String name, double duration, int fileSize)
      {
          sin.setArtist(artist);
          sin.setName(name);
          sin.setDuration(duration);
          sin.setFileSize(fileSize);
      }
  
      public String visconfir()
      {
          if (a != null) return("You have imported: "+sin.getName()+"by"+sin.getArtist()+"which is"
                  +sin.getFileSize()+"kB and"+sin.getDuration()+"long(mm.ss)");
          else return("Error - No file imported to database memory slot a");
      }
  }
  </code></pre>
  
  <p>Can anybody help me out with this?</p>