-3

Can compareTo compare 3 integers? Reason I am asking is because I need to have a method that compares the month, day, and year to see if they are equal.

JetSeeker
  • 1
  • 1
  • is there some particular language or framework or library or something you are working with? – stew Nov 18 '14 at 04:14
  • Special sp = new Special(); //dd, mo, and yy are Strings entered by the user //and read using the Scanner class if (sp.test(dd,mo,yy)) System.out.println(dd +"\\"+ mo + "\\" + yy + " is special"); else System.out.println(dd +"\\"+ mo + "\\" + yy + " is NOT special"); – JetSeeker Nov 21 '14 at 05:29
  • I was given the above ^ code. From what I understand, this is the main method. What I need is to send that information (dd, mo, yy) to a method so that it will test to see if all of them are equal. For example, if the date is 11/11/11, then it's equal. If not, it will print it is not special. – JetSeeker Nov 21 '14 at 05:31

1 Answers1

0

No, the traditional definition of compareTo only takes one argument - the object you're comparing against.

You should use an object that encapsulates the month, day, and year - that should be what you pass to your compareTo method instead of the raw values.

Makoto
  • 104,088
  • 27
  • 192
  • 230