[置顶] String的判断方法
2016-05-14 15:33
260 查看
/*
* public boolean equals(object obj);
* public boolean equalsIgnoreCase(String str);
* public boolean contains(String str);//判断是不是包含字符串
* public boolean startsWith(String str)//判断是不是以指定位置开始
* public boolean endsWith(String str)//判断是不是以指定位置结束
* public boolean isEmpty();//判断字符串是不是为空
* */
public class PanDuanMethod
{
public static void main(String[] args)
{
String s1="Hello";
String s2="HelloWorld";
String s3=null;//对象不存在,空指针
String s4="";
System.out.println(s2.contains(s1));//true
System.out.println(s2.startsWith("He"));//true
System.out.println(s2.endsWith("ld"));//true
//System.out.println(s3.isEmpty());//空指针异常
System.out.println(s4.isEmpty());//true
}
}
* public boolean equals(object obj);
* public boolean equalsIgnoreCase(String str);
* public boolean contains(String str);//判断是不是包含字符串
* public boolean startsWith(String str)//判断是不是以指定位置开始
* public boolean endsWith(String str)//判断是不是以指定位置结束
* public boolean isEmpty();//判断字符串是不是为空
* */
public class PanDuanMethod
{
public static void main(String[] args)
{
String s1="Hello";
String s2="HelloWorld";
String s3=null;//对象不存在,空指针
String s4="";
System.out.println(s2.contains(s1));//true
System.out.println(s2.startsWith("He"));//true
System.out.println(s2.endsWith("ld"));//true
//System.out.println(s3.isEmpty());//空指针异常
System.out.println(s4.isEmpty());//true
}
}
相关文章推荐
- JSP EL表达式详细介绍
- oracle 中有三张表查找oracle中的所有包,包体等
- arm-linux交叉编译环境搭建及交叉工具链 (JZ2440v2)
- Apache安装
- 查询job
- [置顶] String的获取方法
- 创建job
- 【Linux开发】彻底释放Linux线程的资源
- 小酌重构系列目录汇总
- HTTP的请求头标签 If-Modified-Since
- java集合相关知识
- UVA10935
- 使用date对象显示系统当前时间并自动更新
- 小酌重构系列目录汇总
- Android笔记hm001
- [置顶] 遍历获取字符串的的每个字符
- 禁止页面缓存的几种方法分享
- 网络流二十四题之十 —— 星际转移问题(HOME)
- tftp32作为dhcp服务器
- 大道至简第六章读后感