[5568] in java-interest

home help back first fref pref prev next nref lref last post

Re: Integer and int

daemon@ATHENA.MIT.EDU (Mike Paluka)
Fri Feb 16 19:03:01 1996

Date: Fri, 16 Feb 1996 14:28:38 -0800
To: Kwan Chiu Yin <cscykwan@ug.cs.ust.hk>
From: Mike Paluka <mikep@exmachina.com>
Cc: java-interest@java.sun.com

At 03:25 AM 2/17/96 +0800, you wrote:
>Hello all,
>	Here is a stupid question: What is the different between Integer and int
>in java ? I have the following error while I use : count++ where count is 
>a Integer..
>
>	"Incomaptible type +. Can't covert java.lang.Integer to int.
>
>ALex
>

"int" is an intrinsic datatype.  "Integer" is a class.  Since java does not
support operator overloading, I don't think that you'll be able to apply
the "++" directly.

You acutally have to do this:

        Integer iobj = new Integer(5);                  // Set init value.
        iobj = new Integer( iobj.intValue() + 1 );      // Incr. value.

Therefore, before you decide whether to use 'int' or 'Integer', you must
consider how you will use the value.


end
**************************
From : Michael J. Paluka
At   : mikep@exmachina.com

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post