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.isDigit(ch[x])) { count++; } } System.out.println("Number of Numbers are "+count); } }
Enter String : Sateesh@1222
Number of Numbers are 4