I have this code which displays the letters of the alphabet. I am trying to get the JOptionPane to display the first six letters of the alphabet
However when I try and just display the 6 letters, it displays all of the alphabet letters first, which is not what I want it to do.
Here is my code
class Alphabet extends JFrame
{
public static void main(String args[])
{
char[] alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
StringBuilder builder = new StringBuilder(alphabet.length);
for (int i = 0; i < alphabet.length; builder.append(alphabet[i++])) builder.append("\n");
{
JOptionPane.showMessageDialog(null, builder.toString(), "All the letters of the alphabet", JOptionPane.INFORMATION_MESSAGE);
}
for(int i = 0; i < alphabet.length-20; builder.append(alphabet[i++])) builder.append("\n");
{
JOptionPane.showMessageDialog(null, builder.toString(), "First 6 letters of the alphabet", JOptionPane.INFORMATION_MESSAGE);
}
}
}
Any help would be appreciated.