您的位置:首页 > 其它

判断字符串中是否有空格

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"));

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: