Dave's Brain

Browse - Programming Tips - How can I put a special value into an int to indicate something

Date: 2013oct15
Language: Java

Q.  How can I put a special value into an int to indicate something
about it?  I get an error doing:

int myint = null;
A. You can not set int to null. But you can use Integer, like this;
Integer myint = null;
Just remember to use myint.equals(something) instead of == Another approach:
int myint = Integer.MAX_VALUE; int myint = Integer.MIN_VALUE;

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.