commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shing Hing Man <>
Subject [Math] Frequency : Is int comparable to Integer through default comparator
Date Wed, 11 Aug 2004 12:19:45 GMT
Deal all,
   It would be appreciated if someone could clarify
the following 

My version of  org.apache.commons.math is dated 10
August, 2004.
The following snippet piece of code is from

  Frequency f = new Frequency();
        f.addValue(new Integer(1));   // (*)
        f.addValue(new Long(1));
        f.addValue(new Integer(-1));
        System.out.println(f.getCount(1));   //
displays 3
        System.out.println(f.getCumPct(0));  //
displays 0.2
        System.out.println(f.getPct(new Integer(1))); 
// displays 0.6
        System.out.println(f.getCumPct(-2));   //
displays 0
        System.out.println(f.getCumPct(10));  //
displays 1

When I run it, I got the following exception at line

Exception in thread "main"
java.lang.IllegalArgumentException: Value not
comparable to
 existing values.

It looks as though the default comparator can not
compare primitive type int with
Integer object. I thought this piece of code is
supposed to demonstrate the otherwise.

Thanks in advice for your help !


Home page :

___________________________________________________________ALL-NEW Yahoo! Messenger - all
new features - even more fun!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message