import java.util.ArrayList;
import java.util.List;
/**
* 这个例子来源于一个搜索条件业务逻辑产生的bug
* 查询sql明明写的是模糊查询,但是在这种业务逻辑
* 下去写却不能生成模糊查询的效果.
* @author tgy
*
*/
public class TestContains {
public static void main(String[] args) {
List<String>total=new ArrayList<>();
total.add("hello133");
total.add("word2007");
total.add("red hat linux");
//源代码业务逻辑的错误写法
System.out.println(total.contains("word2007"));//true
System.out.println(total.contains("word"));//false
//经过我修改后的写法:这样就可以产生模糊查询的效果了
System.out.println(total.toString().contains("word"));//true
}
}
import java.util.List;
/**
* 这个例子来源于一个搜索条件业务逻辑产生的bug
* 查询sql明明写的是模糊查询,但是在这种业务逻辑
* 下去写却不能生成模糊查询的效果.
* @author tgy
*
*/
public class TestContains {
public static void main(String[] args) {
List<String>total=new ArrayList<>();
total.add("hello133");
total.add("word2007");
total.add("red hat linux");
//源代码业务逻辑的错误写法
System.out.println(total.contains("word2007"));//true
System.out.println(total.contains("word"));//false
//经过我修改后的写法:这样就可以产生模糊查询的效果了
System.out.println(total.toString().contains("word"));//true
}
}