Venamus Venamus - 1 month ago 11
Java Question

How do i display multiple MessageDialog with JOptionPane

How do I display a message dialog for every char in a string with the

JOptionPane
?
I'm converting the string to char already and storing it in an
ArrayList
but I cannot make 1 char appear for every
JOptionPane
.

Here's my code:

public static void main(String[] args) {
ArrayList<Character> arr = new ArrayList<Character>();

String oracion = JOptionPane.showInputDialog(null,"Favor Ingrese oracion: ");

for(int i=0;i<oracion.length();i++)
{
arr.add(oracion.charAt(i));
JOptionPane.showMessageDialog(null, arr);

}

Answer

You should replace code

arr.add(oracion.charAt(i));
JOptionPane.showMessageDialog(null, arr);

with

JOptionPane.showMessageDialog(null, oracion.charAt(i));
Comments