Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Check if a variable type is Object[] and only Object[]!

PatchaFeb 21 2012 — edited Feb 22 2012
Hi all!

Maybe this is a newbee question... but a similar situation never happened to me before!

I have a method which accept an Object[] parameter.
But the particularity of the method is that I need to check if the type of the given parameter is actualy Object[] only !!!

As to say that any other kind of array have to return false after a check... like String[], Number[] or whatever...

For what I know "*instanceof Object[]*" always return true 'cause all classed inheredit from Object (except on array of primitives, which actually can't be passed as argument here).
So how I can get false if the type of the given array parameter is not exactly "*Object[]*"?
This post has been answered by gimbal2 on Feb 21 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2012
Added on Feb 21 2012
12 comments
351 views