import javax.swing.JOptionPane;
import java.util.Arrays;
class NameHolder {
String[] names = new String[10];
public NameHolder() {
int i;
String op = "";
// Get names
for(i = 0; i < names.length; ++i)
names[i] = (String)JOptionPane.showInputDialog(null, "Please enter a name:");
// Sort names
Arrays.sort(names);
// Join names
for(i = 0; i < names.length; ++i)
op += names[i] + "\n";
// Output names
JOptionPane.showMessageDialog(null, op);
}
public static void main(String[] args) {
// Instantiate.
new NameHolder();
}
}There are a few other things you might want to do (such as check if the entered value is empty or null [the user pressed cancel]), but that's the core of it.