I will go with StringBuffer or StringBuilder. Something like:
StringBuffer
StringBuffer sb = new StringBuffer();
for (char alphabet = 'a'; alphabet <= 'z'; alphabet++) {
sb.append(alphabet);
System.out.println(sb.toString());
}
StringBuilder
StringBuilder sb = new StringBuilder();
for (char alphabet = 'a'; alphabet <= 'z'; alphabet++) {
sb.append(alphabet);
System.out.println(sb.toString());
}
String vs StringBuffer vs StringBuilder:
String: It is immutable, so when you do any modification in the string, it will create new instance and will eatup memory too fast.
StringBuffer: You can use it to create dynamic String and at the sametime only 1 object will be there so very less memory will be used. It is synchronized (which makes it slower).
StringBuilder: It is similar to StringBuffer. The olny difference is: it not synchronized and hence faster.
So, better choice would be StringBuilder. Read more.
Using Java 8
StringBuilder sb = new StringBuilder();
IntStream.range('a', 'z').forEach(i -> {
sb.append((char) i);
System.out.println(sb.toString());
});