Format names to title case
Create a List

List&lt;String&gt; al = new ArrayList&lt;String();


and add (you can also use something like while(! stringRead.isEmpty()) {..} )

name = Keyboard.readChar()).toLowerCase();
al.add(name.substring(0, 1).toUpperCase() + name.substring(1));


EDIT after comment

1°) then Sort (the list is 'cloned') and print directly frome the Constructor return This solution is recommended to protect data published in a Web page.

System.out.println(new TreeSet&lt;String&gt;(al).toString());


2°) The List is sorted then printed

Collections.sort(al);
System.out.println(al.toString());