Я устанавливаю программу чата. Подскажите пожалуйста как поменять
цикл for в коде и цикл while в коде.
Я пробовал:
int j = 0;
while(j<numinputs()){
...
j++;
}
...
String[] inputs;
inputs = new String[numinputs];
int i = 0;
while (i < numinputs) {
inputs[i] = JOptionPane.showInputDialog(null, "Please enter key word " + (i + 1) + " ");
if (inputs[i].contains("?") || inputs[i].isEmpty()) {
JOptionPane.showMessageDialog(null, "Invalid Response");
} else
i = i + 1;
}
System.out.println(Arrays.toString(inputs));
for (int j = 0; j < numinputs; j++) {
String search = JOptionPane.showInputDialog("Tell me more about" + " " + inputs[j]);
System.out.println(search);
if (search.contains("exit")) {
System.exit(0);
}
}
}
Вот код, который я пытаюсь изменить:
inputs = new String[numinputs];
int i = 0;
while (i < numinputs) {
inputs[i] = JOptionPane.showInputDialog(null, "Please
System.out.println(Arrays.toString(inputs));
for (int j = 0; j < numinputs; j++) {