判断字符串中是否有空格
2012-09-22 19:03
281 查看
package com.interview.demo;
import org.junit.Test;
public class WhiltCat{
public static boolean hasBlank(String str){
if(str.startsWith(" ")||str.endsWith(" ")){
return true;
}else{
String s[] = str.split(" +");
System.out.println(s[0]);
if(s.length==1){
return false;
}else{
return true;
}
}
}
public static void main(String[] args){
System.out.println(hasBlank("te st"));
}
@Test
public void testFun(){
System.out.println(hasBlank("te st"));
}
}
import org.junit.Test;
public class WhiltCat{
public static boolean hasBlank(String str){
if(str.startsWith(" ")||str.endsWith(" ")){
return true;
}else{
String s[] = str.split(" +");
System.out.println(s[0]);
if(s.length==1){
return false;
}else{
return true;
}
}
}
public static void main(String[] args){
System.out.println(hasBlank("te st"));
}
@Test
public void testFun(){
System.out.println(hasBlank("te st"));
}
}
相关文章推荐
- iOS判断字符串内容是否全部为 空格
- 判断字符串是否包含空格或在全角状态下输入
- js判断输入字符串是否为空、空格、null总结
- java 判断字符串中是否含有空格
- Javascript中去除两边的空格和JS中判断字符串中是否包含某字符
- js判断输入字符串是否为空、空格、null的方法总结
- js判断输入字符串是否为空、空格、null总结
- 判断字符串内容是否全是空格
- 去掉字符串中的空格和回车 获取键盘高度 判断字符串是否为空 swift
- JAVA判断字符串是否为空,是否只有空格
- ""(空字符串) 、" "(空格字符串)、empty() 判断字符串是否为空
- java 判断字符串是否为空,空字符串,或者空格
- flex 判断字符串中是否含有空格
- 判断一个字符串是否全为空格的方法
- 判断输入字符串是否由空格、制表符、回车符、换行符组成的字符串
- jquery判断字符串是否有空格。并去除前后空格
- js判断输入字符串是否为空、空格、null的方法总结
- IOS判断字符串是否有空格实例
- iOS判断字符串是否包含空格
- Java: 判断字符串之间 是否存在空格