Como faço para permitir que o 3º nome possa ser nulo?
import javax.swing.JOptionPane;
public class Teste {
public static void main(String[] ar) {
String[] msg = new String[3];
for(int i=0; i<msg.length; i++){
msg[i] = JOptionPane.showInputDialog("Digite o " + (i+1) + "º nome");
}
for(int i=0; i<msg.length; i++){
if(msg[i] == null || msg[i].equals("")){
System.out.println("Preencha o " + (i+1) + "º nome");
}
}
System.exit(0);
}
}