I got it working but it is also counting the spaces between the words that are being typed. All i care is for the letters to be count and not the spaces. How or what can i do to change this? where am i messing up or missed something
import java.util.Scanner;
public class LetterCount
{
public static void main (String[] args)
{
System.out.println("Type something ");
Scanner n = new Scanner (System.in);
String s = "";
s = n.nextLine();
char []c = s.toCharArray();
int sz = c.length;
int i =0, j=0, counter=0;
for (i=0; i<sz; i++){
counter =0;
for(j=0; j<sz; j++)
{
if (j< i&& c[i] == c[j])
{
break;
}
if (c[j] == c[i])
{
counter++;
}
if (j==sz-1)
{
System.out.println("the character "+c[i]+" is present "+counter+" times");
}
}
}
}
}