Suggestions?

Trying to write a prog that reads a line of text and outputs all the letters that occur in the text along w/the numbers of time each letter occurs

To find the letter can I use something like this:

int letterindex;

letterindex = (int) letter - (int) 'A' ;

return letterindex;

And to write out the frequencyarray:

for (int i = 0 <26; i++)

{

if (letterfrequency !=0)

System.out.println((char) (i + 65) + "" +

letterfrequency;

Anyone with better suggestions

I am trying to write this as simple as possible

[606 byte] By [hamaroy] at [2007-9-26 12:37:51]
# 1

maybe eg,

private final static int AA = ( (int) 'A' );

private final static int EE = ( (int) 'E' );

private final static int II = ( (int) 'I' );

private final static int OO = ( (int) 'O' );

private final static int UU = ( (int) 'U' );

private final static int ZZ = ( (int) 'Z' );

private int[] alphabetCounts = new int[ 26 ];

char c = Character.toUpperCase( c );

int i = (int) c;

alphabetCounts[ i - AA ]++;

mchan0 at 2007-7-2 11:56:22 > top of Java-index,Archived Forums,Java Programming...