hi ,
i am tryin to put all the upper case alphabets in an array list and , then i want it to print on screen , but for some particular reason i am getting no result but a strange output.
here is the code and result:
void buildAlphabet()
{
ArrayList al = new ArrayList();
for ( int i = 1 ; i<=26;i++)/***Goes accordin to the ASCII code*******/
{
al.add(i,(char)(i+64));
}
System.out.print("Contents of array : " +al);
}
result:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.add(ArrayList.java:367)
at alpha_freq.buildAlphabet(alpha_freq.java:13)
Any clue abt this ? , i will appreciate help thanks