判断字符串为空的方法

来源:互联网 发布:如何进入it行业 知乎 编辑:程序博客网 时间:2024/05/21 10:46
字符串为空有两种情况:1、"" 2 、null  String string= "";   //方法一 为""返回true 负责返回false 此处返回true   System.out.println(string.isEmpty()); //方法二 为""返回true 负责返回false 此处返回true     System.out.println(string.equals("")); //方法三 为null返回true 负责返回false 此处返回false     System.out.println(string == null);

0 0
原创粉丝点击