Check which Button object is clicked using JavaFX
<p>I am making a basic calculator but I am unsure of how to check if a certain <code>Button</code> has been clicked. I want to use an array of Button objects and then check to see if the button clicked matches a button object in the array. My code for this is below.</p>

<pre><code>Button[] digitButtons = { bt0, bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9 };

for (int index = 0; index &lt; 9; index++) {
    int position = -1;
    if (buttonClicked == digitButtons[index]) {
        position = index;
        break;
    }
}
</code></pre>