此代码不起作用。请帮助修复它.............................................. .................................................. .................java使用递归查找字符串中的子串
/**
Recursive method for looking for a substring in a string.
@param text look in
@param target look for as substring
@return true if target is a substring of text
*/
public static boolean find(String text, String target)
{
//-----------Start below here. To do: approximate lines of code = 4
// 1. base case: null
if (text == null) {return false;}
//2. base case: target too long
if (target.length() > text.length()) {return false;}
//3. base case: same length
if (text.length() == target.length()) {return false;}
//4. base case: startsWith OR 5. recursive case
return true;
}
请仔细阅读[如何提问](https://stackoverflow.com/questions/如何提问),然后[编辑]你的问题。 –
你正在得到什么错误? –
我在这里没有看到递归。我认为你的代码不完整 – Rami