Exception in thread
I keep getting this error and i cant figure out what is wrong.
Exception in thread "main" java.lang.NullPointerException
at pmusic.MusicApp.main(MusicApp.java:93)
Java Result: 1
here is my code:
package pmusic;
import java.io.*;
public class MusicApp
{
public static void main(String[] args)
{Artist[] myArtists = new Artist[1];
Albums[] myAlbums = new Albums[2];
Songs[] mySongs = new Songs[12];
int s=0, al=0, ar=0, count=0;
try
{
String line = "";
BufferedReader in = new BufferedReader(new FileReader("small list.csv"));
while (((line = in.readLine()) != null) && (count<23))
{
String[] fields = line.split(",");
{
if (fields[0]=="")
{
if (fields[1]=="")
{
int trackNumber = Integer.parseInt(fields[4]);
String trackName = fields[5];
mySongs[s] = new Songs(trackName, trackNumber);
s++;
}
else
{String album = fields[1];
int rank = Integer.parseInt(fields[2]);
int year = Integer.parseInt(fields[3]);
myAlbums[al] = new Albums(album, rank, year, mySongs);
s=0;
al++;
}
}
else
{
String artistname = fields[0];
myArtists[ar] = new Artist(artistname, myAlbums);
al=0;
}
}
}
}
catch (IOException e)
{
System.out.println("There was a problem with the file");
e.printStackTrace();
}
System.out.println(mySongs[0].toString());
}
}
the error is on the System.out.println(mySongs[0].toString());
can anyone help?

