import java.util.*; class countLetters { public static void main(String s[]) { Scanner sc = new Scanner(System.in); int count = 0; char ch; System.out.println("Enter The String To Count No. Of Letters : "); String str = sc.nextLine(); for(int i=0;i<str.length();i++) { ch = str.charAt(i); if(ch!=' ') { count++; } } System.out.println("The no of letters in given string is : " + count); } }