Hey!
Im new to java...and programming in general. Im trying to make a program where the user can input 3 fields. I want the program to tell the user what fields the user forgot to fill in.
Can I use an arraylist for that? Help would be greatly appreciated It doesnt work like iwaHere is my code:
for (;;) { try { int svar = JOptionPane.showConfirmDialog(Main.this, reg, "Registrera deltagare", JOptionPane.OK_CANCEL_OPTION); if (svar != OK_OPTION) return; ArrayList<String> errorlog = new ArrayList<String>(); String name = reg.getName(); String country = reg.getCountry(); String age = reg.getAge(); if (age.length()==0); errorlog.add("Ålder"); if (name.length()==0) errorlog.add("Namn"); if (country.length()==0) { errorlog.add("Land"); System.out.println(age); JOptionPane.showMessageDialog(Main.this, "You forgot to fill in: "+errorlog, "Problem", JOptionPane.ERROR_MESSAGE); } else { int age2 = Integer.parseInt(age); People p = new People(name, country, age2); persons.add(p); startnr++; break; } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(Main.this, "Only numbers in this field, please.", "Fel", JOptionPane.ERROR_MESSAGE); } }