0

This is what I have so far:

import javax.swing.JOptionPane;

public class question {

     public static void main(String [] args) {

         final int totalMaxParticipants = 283;

         String[] name = new String[totalMaxParticipants];
         getName(name);
     }


    public static void getName(String [] name) {
        final String Sentinal = "Q";

        for (int i = 0; i < name.length; i++) {

        name = JOptionPane.showInputDialog("Enter name: ");

        while (!name.equals(Sentinal)) {
        try {
           name = name;
        }
        catch(NumberFormatException e) {
           JOptionPane.showMessageDialog(null, "Error");
        }
        name = JOptionPane.showInputDialog("Enter name: ");   
     }
  }
}

I keep getting an error saying String cannot be converted to String[] and I cannot figure out how to fix it.

End
  • 1
  • 4
  • 2
    Look up Lists: https://docs.oracle.com/javase/8/docs/api/java/util/List.html. Lists are dynamic, in that you can add to them on the fly without having to specify the size beforehand –  Apr 27 '17 at 15:03
  • Very bad formatting – kourouma_coder Apr 27 '17 at 15:05
  • You should use plural for your arrays. So `String[] name` becomes `String[] names`. Then you'll see that `names = "Smith"` is somewhat wrong. You try to assign a string to an array, but you have to assign a string to a position inside the array: `names[0] = "Smith"`. But @Houseman is right. You should use a List like an ArrayList. – Obenland Apr 27 '17 at 15:12
  • I can't import ArrayList – End Apr 27 '17 at 15:50

0 Answers0