Skip to content

Commit d7349fe

Browse files
committed
Caching getScreenDevices() output in a local variable.
1 parent 2d8a27f commit d7349fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/jdk/java/awt/GraphicsDevice/CheckDisplayModes.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ public class CheckDisplayModes {
3535

3636
public static void main(String[] args) {
3737
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
38-
for (GraphicsDevice gd : ge.getScreenDevices()) {
38+
GraphicsDevice[] allDevices = ge.getScreenDevices();
39+
40+
for (GraphicsDevice gd : allDevices) {
3941
System.out.println("Available screen device: " + gd.getIDstring());
4042
}
4143

42-
for (GraphicsDevice graphicDevice : ge.getScreenDevices()) {
44+
for (GraphicsDevice graphicDevice : allDevices) {
4345
System.out.println("On screen device " + graphicDevice.getIDstring());
4446
if (!graphicDevice.isDisplayChangeSupported()) {
4547
System.err.println("Display mode change is not supported on this host. Test is considered passed.");

0 commit comments

Comments
 (0)