Skip to content

Commit 2015244

Browse files
authored
Merge pull request #1564 from cfsimplicity/patch-4
Java Class Interaction: add how to specify enums using variables
2 parents 0bcadea + 9735412 commit 2015244

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

docs/recipes/java-class-interaction.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ state = java:Thread$State::RUNNABLE;
162162
allStates = java:Thread$State::values();
163163
dump( allStates );
164164
```
165+
To specify an enum using a variable, use square bracket notation:
166+
```javascript
167+
import java.util.concurrent.TimeUnit;
168+
selectedTimeUnit = "MINUTES";
169+
selectedEnumObject = TimeUnit::[ selectedTimeUnit ];
170+
dump( selectedEnumObject.name() ); // MINUTES
171+
```
165172

166173
## Class Reflection (Advanced)
167174

0 commit comments

Comments
 (0)