nulls

Hi

i have a method that takes a name of a client (i have an array of client object) and searches the array till it finds the client, setting the varialbe poss to the index of the serched client so that this client can be displayed. i instantiated the poss variable to null initially so that i can put in an if statement to check if poss = null, display the sentance 'client was not found', the compiler didnt like this, it expects a int tipe not a null tipe. i cant set poss to 0 becoz when i want to display the client at index [poss] it will display client 0 regardless of if i want to or not, can someone tell m another way to do this? as my idea never worked

Cheers

[690 byte] By [Aussie_Nerda] at [2007-11-27 5:38:31]
# 1
Set poss to -1 initially, and change your if statement to if(poss == 1) by the way, there is only one 's' in position, so you should probably just call the variable pos.
RedUnderTheBeda at 2007-7-12 15:12:13 > top of Java-index,Java Essentials,New To Java...
# 2
Only objects can be set to null and ints are primitives not objects. For you purposes give poss an initial value of a negative number since all objects in your array will have positive or zero indicies.
floundera at 2007-7-12 15:12:13 > top of Java-index,Java Essentials,New To Java...
# 3
thanx heaps, that seems so logical! lol y couldnt I figure that out! haha
Aussie_Nerda at 2007-7-12 15:12:13 > top of Java-index,Java Essentials,New To Java...
# 4
> Only objects can be set to null <pb>References, actually.</pb>
jverda at 2007-7-12 15:12:13 > top of Java-index,Java Essentials,New To Java...
# 5
:p
floundera at 2007-7-12 15:12:13 > top of Java-index,Java Essentials,New To Java...