| Author |
reflexion and enum
|
mark smith
Ranch Hand
Joined: Apr 05, 2005
Posts: 240
|
|
hi
i use this code
getGlass return an enum
is there a way to do that with reflexion?
thanks
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
is there a way to do that with reflexion?
Not sure what you are asking. Can you elaborate? enums are just objects, so the reflection library should work for them too.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
mark smith
Ranch Hand
Joined: Apr 05, 2005
Posts: 240
|
|
this line of code is in a class X who extends Y
this class Y have
Glass is an enum
so my question is how to be able to do the same thing then
but with reflexion?
i tried
but i'm not able to access the field (tickness)
any idea?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
mark smith wrote:
but i'm not able to access the field (tickness)
any idea?
Try...
BTW, if you know the exact method to execute, and the exact field to get, why do you need reflection? The way you are doing it now is much easier than using reflection.
Henry
|
 |
mark smith
Ranch Hand
Joined: Apr 05, 2005
Posts: 240
|
|
thanks Henry Wong that work...
the method can change... not the field...
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
mark smith wrote:thanks Henry Wong that work...
the method can change... not the field...
If the field doesn't change, then there is no reason to use reflection to get it... you can simply cast and dereference it.
Henry
|
 |
 |
|
|
subject: reflexion and enum
|
|
|