# "Variable in variable"/putting a variable in the name behind void / calling methods by name

**URL:** <https://discourse.processing.org/t/variable-in-variable-putting-a-variable-in-the-name-behind-void-calling-methods-by-name/16935>\
**Category:** Coding Questions\
**Created:** [January 7, 2020, 4:26pm UTC](https://discourse.processing.org/t/variable-in-variable-putting-a-variable-in-the-name-behind-void-calling-methods-by-name/16935 "2020-01-07T16:26:16Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [January 7, 2020, 6:26pm UTC](https://discourse.processing.org/t/variable-in-variable-putting-a-variable-in-the-name-behind-void-calling-methods-by-name/16935/8 "2020-01-07T18:26:12Z")

</div>

Runnable is actually there since Java 7. I use it as a simple way to store callbacks. For instance

```
myButton.setCallback(this::changeColor);

```

and inside button:

```
void setCallback(Runnable callback) { 
  // store callback locally for later invocation using theCallback.run()
}

```

ps. sorry for going off-topic!

---

_[View the full topic](https://discourse.processing.org/t/variable-in-variable-putting-a-variable-in-the-name-behind-void-calling-methods-by-name/16935)._
