Re: Test If Int Has Not Been Set
- From: Patricia Shanahan <pats@xxxxxxx>
- Date: Thu, 26 Oct 2006 05:35:27 GMT
dimo414 wrote:
I have an array of integers, which I set via a recursive function.
Obviously, I don't want to set them more than once, so I want to test
if, for instance myVar[10] == null. But of course, that doesn't work,
since integer's are not null before they've been given a value.
How can I test if a value has been set or not?
1. If the integers have an out-of-bound value, initialize them to that
first. For example, if the values you set are all non-negative,
initialize to -1. If they must be positive, just check for myVar[10]==0.
2. Use Integer and check for null, As Andrew suggested.
3. Use a separate boolean array, the same length, and set the boolean at
an index to true when you set the int with the same index.
4. Structure your logic so that you only attempt to set each element once.
Patricia
.
- Follow-Ups:
- Re: Test If Int Has Not Been Set
- From: Thomas Weidenfeller
- Re: Test If Int Has Not Been Set
- References:
- Test If Int Has Not Been Set
- From: dimo414
- Test If Int Has Not Been Set
- Prev by Date: Re: Test If Int Has Not Been Set
- Next by Date: Re: load properties from xml into objects
- Previous by thread: Re: Test If Int Has Not Been Set
- Next by thread: Re: Test If Int Has Not Been Set
- Index(es):