mardi 1 mars 2016

How to use regular expression in an if condition in java

Hi I am only two semesters in my programming education, so if my question seems dumb I apologize in advance. For my program I am required to look at string and determine if the string has ing in it that specific order. I split the string by the a space since in my test class it has all the words in the string separated by spaces. The part that i am stuck on is making a if statement that checks to see if the string at index i has ing in that order. Here is my code

public class EndsWith
{
   public static void endsWithIng (String s)
   {

      String [] a = s.splits(" ");

      int i;
      for(i=0;i<a.lenght;i++)
      {

         if()
         System.out.print(a[i] + "");

      }     

   }

}

Aucun commentaire:

Enregistrer un commentaire