功能:比较两个字符串是否相等
1.引入依赖
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency>
2.代码如下
public class Maintest { public static void main(String[] args) { System.out.println(StringUtils.equals(“”, “”)); System.out.println(StringUtils.equals(null, null)); System.out.println(StringUtils.equals(null, “”)); System.out.println(StringUtils.equals(“”, null)); System.out.println(StringUtils.equals(null, “”)); System.out.println(StringUtils.equalsIgnoreCase(“ss”, “Ss”)); }}
输出入下: