java code for calculating the characters in java ;
class anonymous
{
static int charcount(String s)
{ int count=0;
for(int i=0;i<s.length();i++)
{
char ch=s.charAt(i);
String s1=s.valueOf(ch);
byte b[]=s1.getBytes();
String s2=new String(" ");
byte c[]=s2.getBytes();
if(b[0]==c[0])
{
count=count;
}
else
{
count=count+1;
}
}
return count;
}
public static void main(String a[])
{
System.out.println(charcount("wings of fire by Mr. Kalam"));
}
}
class anonymous
{
static int charcount(String s)
{ int count=0;
for(int i=0;i<s.length();i++)
{
char ch=s.charAt(i);
String s1=s.valueOf(ch);
byte b[]=s1.getBytes();
String s2=new String(" ");
byte c[]=s2.getBytes();
if(b[0]==c[0])
{
count=count;
}
else
{
count=count+1;
}
}
return count;
}
public static void main(String a[])
{
System.out.println(charcount("wings of fire by Mr. Kalam"));
}
}


0 comments:
Post a Comment