I am just learning Java and am trying to use variables from objects that I passed into another method. Can someone help me here
package data;
public class Data {
private int day, month, year;
public Data(int day, int month, int year)
{
this.day = day;
this.month = month;
this.year = year;
}
public int getDay()
{
return day;
}
public int getMonth()
{
return month;
}
public int getYear()
{
return year;
}
void setDay(int day)
{
this.day = day;
}
void setMonth(int month)
{
this.month = month;
}
void setYear(int year)
{
this.year = year;
}
}
int compareTo (Date current, Date former)
{
if(current.year < former.year)
{
return 0;
}
else
if(current.month < former.month)
{
return 0;
}
else
if(current.day < former.day)
{
return 0;
}
else
if(current.year == former.year && current.month == former.month
&& current.day == former.day)
{
return -1;
}
else
{
return 1;
}
}
It gives an error on the line with the close bracket after the return statements and on the line 41. Everything else works fine.