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
Re: Exception in thread "main" java.lang.NullPointerException problem.......
Please use code tags when posting code and also post the full error message and stack trace as it tells us exactly what and where the error is.
BTW prompting for a reply after waiting only 4 hours is not going to help your question get answered - we all help out here in our spare time so I'm afraid you just have to wait until someone has time to answer your post.
Bookmarks