for (int i = 0; i < 10; i++) { sampleArraybuttons [i] = new JButton(String.valueOf(i)); // String.valueof(i) Converts the integer value of i into String Value // and adds it as name of button.