Re: j2s-development] Numbers hashCode()
Brought to you by:
zhourenjian
|
From: Soheil H. Y. <soh...@gm...> - 2006-06-12 19:48:11
|
The problem is solved now. I implement the equals for Long, Integer,
Float and Double.
On 6/12/06, Soheil Hassas Yeganeh <soh...@gm...> wrote:
> Hi,
>
> I'm now doing a lot of tests of java core packages. I found another
> problem caused by using Number.
> The code written bellow does not work. It's about the
> Number.hashCode() the firefox says:
> (Error: Number.prototype.toString called on incompatible Object
> Source File: file:///home/soheil/ws-j2s-svn/net.sf.j2s.lib/j2slib/j2s-core-basic.z.js
> Line: 108)
> ...
> Map x = new HashMap();
> x.put(new Long(3), new Long(2));
> System.out.println(x.get(new Long(3)));
> ...
>
> I've tested workarounds written below. Number.toString() works but
> another problem occures it does not found any thing on the map. I
> think hashCode() and equals() of Long, Integer, ... deosnot work!
> Number.prototype.toString = function(){
> return this + '';
> }
> and
> Number.prototype.toString = function(){
> return new java.lang.String(this + '');
> }
> How this problem can be solved?
> I will report any other java.util prolems as I found them.
> Regards,
> Soheil
>
|