Name: Anonymous 2011-03-09 18:23
public class life{
public static void main(){
char[] alphabet = new char[26];
for(int i=0;i<26;i++){
alphabet[i] = ((char)(i+97)); //Sets the lowercase ASCII letter to it's position in the aplhabet
System.out.println((char)(i+97));//Displays the letter
}
System.out.println(alphabet[0] + alphabet[25]);//should return "az"
}
}
I'm using a for loop to build an array containing the alphabet. It doesn't work.
public static void main(){
char[] alphabet = new char[26];
for(int i=0;i<26;i++){
alphabet[i] = ((char)(i+97)); //Sets the lowercase ASCII letter to it's position in the aplhabet
System.out.println((char)(i+97));//Displays the letter
}
System.out.println(alphabet[0] + alphabet[25]);//should return "az"
}
}
I'm using a for loop to build an array containing the alphabet. It doesn't work.