So when I run this code, I get this "Exception in thread "main" java.lang.NullPointerException" error:


import feiner.bcs345.health.datetime.*;
import java.util.*;
import java.io.*;

public class datetimetest
{

/**
* @param args
*/
public static void main(String[] args)
{
//*******************************************************************************************
//MyDate Test
//*******************************************************************************************
Scanner s = null;
PrintStream ps = null;

MyDate Date1;
MyDate Date2;



// New instance using a default constructor.
Date1 = new MyDate();

//Set methods alter the values.
Date1.SetMonth(2);
Date1.SetDay(2);
Date1.SetYear(2001);

//Print statements output the set values to confirm they are correct.
System.out.print("Month = ");
System.out.println(Date1.GetMonth());

System.out.print("Day = ");
System.out.println(Date1.GetDay());

System.out.print("Year = ");
System.out.println(Date1.GetYear());
System.out.print("\n");



//New instance using a constructor with parameters.
Date1 = new MyDate(3, 3, 2002);

//Print statements output the set values to confirm they are correct.
System.out.print("Month = ");
System.out.println(Date1.GetMonth());

System.out.print("Day = ");
System.out.println(Date1.GetDay());

System.out.print("Year = ");
System.out.println(Date1.GetYear());
System.out.print("\n");



//New instance using a constructor with parameters.
Date1 = new MyDate(4, 4, 2003);

//Read method reads values set by constructor.
Date1.Read(s);

//Write method prints values.
Date1.Write(ps);


}

}





And Here is the class im using with it:

package feiner.bcs345.health.datetime;
import java.util.*;
import java.io.*;

public class MyDate
{
//Attributes
private int Month;
private int Day;
private int Year;

//Behaviors
public int GetMonth() {return Month;}
public int GetDay() {return Day;}
public int GetYear() {return Year;}

public void SetMonth(int m) {Month = m;}
public void SetDay(int d) {Day = d;}
public void SetYear(int y) {Year = y;}

public void Write(PrintStream ps)
{
ps.printf("%d\t%d\t%d\t, Month, Day, Year");
}

public void Read(Scanner s)
{
Month = s.nextInt();
Day = s.nextInt();
Year = s.nextInt();
}

// Default Constructor
public MyDate()
{
Month = 1;
Day = 1;
Year = 2000;
}

// Constructor
public MyDate(int m, int d, int y)
{
Month = m;
Day = d;
Year = y;
}
}





Can someone please help me make the "Read" and "Write" methods work correctly in main? I think it has something to do with initializing the scanner and/or printstream or something i really don't know i'm a beginner. Thanks in advance