class DigitCh
{
int I,len,c=0;
char ch;
public void
showDigits (String str)
{
str=str.trim();
len=str.length ();
for
(i=0;i< len;i++)
{
ch= str.charAt(i);
if(Character.isDigit(ch))
c++;
}
System.out.print(“Total
number of digits in the sentence=”+c);
}
public static void
main(String args[])
{
DigitCh ob=new
DigitCh ();
ob.
showDigits(“abcd123”);
}
}
Related Post: Programs on Character Class
No comments:
Post a Comment