Wednesday, February 25, 2015

Search in a String in a java



Search in a String

public class SearchStringEmp
{
   public static void main(String[] args)
   {
      String strOrig = "Hello readers";
      int intIndex = strOrig.indexOf("Hello");
      if(intIndex == - 1)
      {
         System.out.println("Hello not found");
      }
       else
      {
         System.out.println("Found Hello at index "
         + intIndex);
      }
   }
}
 

No comments:

Post a Comment