Hello,
How do I create a primitive int variable which holds the largest value it
possibly can? I've tried this:
public Integer x = Integer.MAX_VALUE;
public int y = x.intValue();
... but I get an "Incompatible types" error. I can't work out if a) I can do
the operation in 1 graceful statement, or b) if not, how to create a new
Integer and assign the Integer.MAX_VALUE to it.
Thanks.
Mark
Mark - 19 Jan 2005 16:41 GMT
> How do I create a primitive int variable which holds the largest value it
> possibly can?
Bah! Looks like the following works:
public int y = Integer.MAX_VALUE;
Talk about not seeing the wood for the trees...
Mark
Boudewijn Dijkstra - 19 Jan 2005 16:46 GMT
> Hello,
>
[quoted text clipped - 7 lines]
> do the operation in 1 graceful statement, or b) if not, how to create a new
> Integer and assign the Integer.MAX_VALUE to it.
I don't know what planet you are from, but out here we just do:
int x = Integer.MAX_VALUE;
because Integer.MAX_VALUE is declared as an int, not as an object of Integer.