public class ReservationSystem {
static Service p;
public static void main(String[] args) {
String filename = null;
if(args.length == 0)
{
System.out.println("Improper format: filename needed");
System.exit(0);
}
filename = args[0];
File a = new File(filename);
try
{
if (a.exists())
{
System.out.println("File already exist, will proceed to Menu");
p.readfile(filename);
menu();
}
else
{
a.createNewFile();
System.out.println("New file created, will proceed to Menu");
menu();
}
}
I'm having null pointer exception when trying to pass filename into method of another class. the error is on this line p.readfile(filename);
. Can someone suggest a way to fix this.I'm trying to debug this, but I don't understand why the system gave that error when I'm only trying to pass in a string, by the way, the file exist and I was able to trace it until the line of error.