Java tutorial
//package com.java2s; import javax.swing.*; import java.util.Arrays; public class Main { public static void fillComboBox(JComboBox<String> comboBox, String[] values, boolean isToClean, String firstElement) { if (comboBox == null) { return; } if (isToClean) { comboBox.removeAllItems(); } if (firstElement != null) { comboBox.addItem(firstElement); } Arrays.stream(values).forEach(val -> comboBox.addItem(val)); } }