import java.util.Scanner; public class Main { public static void main(String[] args) { int x,n,count=0; String s; char ch[]; Scanner sc=new Scanner(System.in); System.out.println("Enter String :"); s=sc.nextLine(); n=s.length(); ch = s.toCharArray(); for(x=0;x<n;x++) { if(Character.isLetter(ch[x])) { count++; } } System.out.println("Number of letters are "+count); } }
Enter String : sateesh@123
Number of letters are 7