contains() method
authorjihoonl <jihoonl>
Mon, 2 Nov 2009 05:26:35 +0000 (05:26 +0000)
committerjihoonl <jihoonl>
Mon, 2 Nov 2009 05:26:35 +0000 (05:26 +0000)
Robust/src/ClassLibrary/String.java

index 07632bec02607f87dd5b739db3b9c37bcc6b9aef..864574f05b7457a8cdb6808029909997a74140c8 100644 (file)
@@ -400,6 +400,27 @@ public class String {
     splitted.addElement(tmpStr);
 
     return splitted;
+  }
+
+  public boolean contains(String str)
+  {
+    int i,j;
+    char[] strChar = str.toCharArray();
+    int cnt;
+
+    for(i = 0; i < count; i++) {
+      if(value[i] == strChar[0]) {
+        cnt=0;
+        for(j=0; j < str.length() && i+j < count;j++) {
+          if(value[i+j] == strChar[j])
+            cnt++;
+        }
+        if(cnt == str.length())
+          return true;
+      }
+    }
+
+    return false;
 
   }
 }