Я хочу прочитать ввод из нескольких диалоговых окон ввода JOptionPane и распечатать входные данные каждого диалогового окна в диалоговом окне сообщений JOptionPane в одном предложении. Например: Это, есть, сообщение.Печать нескольких диалоговых окон ввода строки JOptionPane в одном предложении
будет выводиться как: Это сообщение
Вот мой код, который я пытаюсь адаптироваться, в настоящее время он вычисляет общее количество символов во всех входах.
// A Java Program by Gavin Coll 15306076 to count the total number of characters in words entered by a user //
import javax.swing.JOptionPane;
public class WordsLength
{
public static void main(String[] args)
{
String words = JOptionPane.showInputDialog(null, "Enter your word: "); // Getting the first word
int length = words.length();
int totallength = length;
int secondaryLength;
do
{
String newwords = JOptionPane.showInputDialog(null, "Enter another word: (Enter nothing to stop entering words) "); // Getting more words
secondaryLength = newwords.length(); // Getting the length of the new words
totallength += secondaryLength; // Adding the new length to the total length
}
while(secondaryLength != 0);
JOptionPane.showMessageDialog(null, "The total number of characters in those words is: " + totallength);
System.exit(0);
}
}