To expand on Jean-Bernard's answer:
String concatenation is done like this in Java:
String s1 = "hello";
String s2 = "world";
String s3 = s1+" "+s2; // "hello world"
Therefore what you want to do is concatenate all of the strings (with a loop) before you show the dialog box.
Which you would do like this:
String collection = "";
for(int i = 0; i < cihpertext.length; i++) {
collection += " "+ciphertext[i];
if(chkEight(i)) [
collection += "\n"
}
}
JOptionPane.showMessageDialog(null, collection);
EDIT: To clarify what your mistake is:
JOptionPane.showMessageDialog(null,"\n\nCiphertext: ");
for (int i = 0; i < ciphertext.length; i++) {
if (chkEight(i)) {
System.out.print("\n");
}
JOptionPane.showMessageDialog(null,ciphertext[i] + " ");
}
In this code you:
Try to print a newline to the terminal if chkEight(i) returns true; this won't append anything to the string.
Then you call showMessageDialog for every iteration in the loop, showing the current ciphertext element plus a space.
Are you sure that you understand your own code?