| Author |
How to know if type is array or not
|
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
|
|
im getting from method the parameters types Class[] types = currentMethod.getParameterTypes(); now i like to know if types[i] is array or not if i do : types[j].getName() im getting only the type name but no indication if its array or not how can i do that ?
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
|
"types[i]" is an instance of java.lang.Class. Did you look carefully at the Javadocs for this class? For example, are there any methods with "array" in their names that look promising?
|
[Jess in Action][AskingGoodQuestions]
|
 |
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
|
|
Hi sorry i meant how to know if its 2 dimensional array simple case to know if its array i will use isArray
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
In Java "2D arrays" are actually arrays of arrays. The Class.getComponentType() method tells you the type of the data an array can hold; for a "2D array", this will be another array type. So something like Of course, this also returns true for "3D", "4D", etc, arrays.
|
 |
 |
|
|
subject: How to know if type is array or not
|
|
|