From e3b58a375a4d76ce44d538876a5260c7a3672923 Mon Sep 17 00:00:00 2001 From: jihoonl Date: Mon, 2 Nov 2009 05:26:35 +0000 Subject: [PATCH] contains() method --- Robust/src/ClassLibrary/String.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Robust/src/ClassLibrary/String.java b/Robust/src/ClassLibrary/String.java index 07632bec..864574f0 100644 --- a/Robust/src/ClassLibrary/String.java +++ b/Robust/src/ClassLibrary/String.java @@ -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; } } -- 2.34.1