Autoboxing and java.lang.Math
From: Oliver Plohmann (oliver_at_plohmann.com)
Date: 07/30/04
- Next message: Esmond Pitt: "Re: RMI binding to SAME port but DIFFERENT IP address on SAME host"
- Previous message: Faiser: "Re: GOF"
- Next in thread: Raymond DeCampo: "Re: Autoboxing and java.lang.Math"
- Reply: Raymond DeCampo: "Re: Autoboxing and java.lang.Math"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Jul 2004 01:45:52 -0700
Hello!
In JDK1.5 Sun has introduced autoboxing. The user does not need to
convert an instance of Integer into an int herself anymore when she
wants to do arithmetic operations with the int. The compiler takes
care of the required conversion. I like this approach since it
preserves the efficiency of primitive data types but lets the user
believe she were dealing with objects.
Now it would be nice to be consequent and move the methods from
java.lang.Math into the respective Number classes. Then, for example,
you could say:
int i = 9;
double root = i.sqrt();
In this case the compiler would convert the second line as
appropriate:
int i = 9;
double root = Math.sqrt(i);
Well, and then it would be nice if you could redefine operators ...
I'm not sure the guys at Sun knew what could break lose if they
introduce this autoboxing stuff ;-). I would be interesting in hearing
some comments about this idea. Comments saying this is crazy are
welcome. I just want to converse the issue a bit.
Regards, Oliver Plohmann
- Next message: Esmond Pitt: "Re: RMI binding to SAME port but DIFFERENT IP address on SAME host"
- Previous message: Faiser: "Re: GOF"
- Next in thread: Raymond DeCampo: "Re: Autoboxing and java.lang.Math"
- Reply: Raymond DeCampo: "Re: Autoboxing and java.lang.Math"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|