Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2012, 09:36 AM   PM User | #1
fairfax
New to the CF scene

 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
fairfax is an unknown quantity at this point
How to check if an array key exists

If I use a variable argument list is there a way to check how many of the variable arguments are set. For example:

public Object method Name(Object req_input, Object... add_inp)

I would like to know if add_input[0] is set, and also the number of add_inp[] entries that are set. Thanks.

Last edited by Fou-Lu; 06-21-2012 at 05:59 PM..
fairfax is offline   Reply With Quote
Old 06-21-2012, 06:02 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Its an array. Use add_inp.length to determine if an offset is available (length is size + 1, so if its 0, you have no data). Try/catch can be used as well, but I would recommend using an if check instead.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:38 PM.


Advertisement
Log in to turn off these ads.