
Hi, my two dates never match using .equals method and two different constructors.
o/p is like
examples.Pdate@192d342Blah dateexamples.Pdate@6b97fd
Code:
package examples;
public class Pdate{
int Pday;
int Pmonth;
int Pyear;
int d1,d2;
Pdate()
{
Pday=2;
Pmonth=1;
Pyear=1988;
}
Pdate(int da,int mo,int ye){
this.Pday=da;
this.Pday=mo;
this.Pday=ye;
}
public static void main(String args[]){
Pdate date1=new Pdate(2,1,1988);
Pdate date2=new Pdate();
{if (date1.equals(date2))
System.out.println(date1+"Awesome date"+date2);
else
System.out.println(date1+"Blah date"+date2);
}
}}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.