I have a list of checkboxes that I would like to disable. Rather than typing
c1.setEnabled(false);
c2.setEnabled(false);
c3.setEnabled(false);
c4.setEnabled(false);
c5.setEnabled(false);
How could I trim this code down by putting them in some sort of group? I have the same issue throughout a lot of my code but with different components. Thanks
In Java 8+, you could use a lambda like
Stream.of(c1, c2, c3, c4, c5).forEach(x -> x.setEnabled(false));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With