write a program to enter a string and find the existence of a character(y/n), occurence of a perticular character with position

class CheckString
 {
  public static void main(String args[])
   {
     String str="kapil";
     int len=str.length();
     char[] a=new char[len];
      for(int i=0;i<len;i++)
       {
         a[i]=str.charAt(i);
         if(a[i]=='a')
          {
           System.out.println("yes charector is exist at the posotion"+i+"  charector="+a[i]);
         }
         else
         {
           System.out.println("not fond charec.");
         }
       }
    }
 }

No comments:

Post a Comment