The code suppose to print names entered by user but it is just printing the null values instead of printing actual names. I am using array to store the names values.
import javax.swing.JOptionPane;
class PrintName {
public static void main(String[] args) {
int nameCount = Integer.parseInt(JOptionPane.showInputDialog(null, " how many NAMES you want to enter?"));
String [] userFirstName = new String [nameCount];
String [] userLastName = new String [nameCount];
for (int i=0; i<nameCount; i++) {
fullName(userFirstName[i], userLastName[i]);
}
for (int i=0; i<nameCount; i++) {
JOptionPane.showMessageDialog(null, userFirstName[i] + "\n" + userLastName[i]);
}
public static void fullName (String firstName, String nLastName) {
firstName = JOptionPane.showInputDialog(null, "What's your first name?");
nLastName = JOptionPane.showInputDialog(null, "What's your last name?");
}
}