@Test public void whenStringFromAToZContainsSubstringStuThenResultTrue() { SubString subStr = new SubString(); String testString = "abcdefghijklmnopqrstuvwxyz"; String testSubString = "stu"; assertThat(subStr.contains(testString,testSubString), is(true)); }
boolean contains(String origin, String sub) { boolean result = false; char[] originChars = origin.toCharArray(); char[] subChars = sub.toCharArray(); for (int i = 0; i < originChars.length - subChars.length; i++) { if (originChars[i] == subChars[0]) { int count = 0; for (int j = 0; j < subChars.length; j++) { if (originChars[i+j] == subChars[j]) { count++; } } if (count == subChars.length) { result = true; } } } return result; }
SubString { boolean contains(String origin, String sub) { boolean result = false; char[] originChars = origin.toCharArray(); char[] subChars = sub.toCharArray(); for (int i = 0; i < originChars.length - subChars.length; i++) { if (originChars[i] == subChars[0]) { int count = 0; for (int j = 0; j < subChars.length; j++) { if (originChars[i+j] == subChars[j]) { count++; } } if (count == subChars.length) { result = true; } } } return result; } }
SubString { boolean contains(String origin, String sub) { boolean result = false; char[] originChars = origin.toCharArray(); char[] subChars = sub.toCharArray(); for (int i = 0; i < originChars.length - subChars.length; i++) { if (originChars[i] == subChars[0]) { int count = 0; for (int j = 0; j < subChars.length; j++) { if (originChars[i+j] == subChars[j]) { count++; } } if (count == subChars.length) { result = true; } } } return result; }  }
SubString { boolean contains(String origin, String sub) { boolean result = false; char[] originChars = origin.toCharArray(); char[] subChars = sub.toCharArray(); for (int i = 0; i < originChars.length - subChars.length; i++) { if (originChars[i] == subChars[0]) { int count = 0; for (int j = 0; j < subChars.length; j++) { if (originChars[i+j] == subChars[j]) { count++; } } if (count == subChars.length) { result = true; } } } return result; }   }
SubString { boolean contains(String origin, String sub) { boolean result = false; char[] originChars = origin.toCharArray(); char[] subChars = sub.toCharArray(); for (int i = 0; i < originChars.length - subChars.length; i++) { if (originChars[i] == subChars[0]) { int count = 0; for (int j = 0; j < subChars.length; j++) { if (originChars[i+j] == subChars[j]) { count++; } } if (count == subChars.length) { result = true; } } } return result; }    }