How can I find whitespace in a String?

后端 未结 14 1047
感动是毒
感动是毒 2020-12-01 05:08

How can I check to see if a String contains a whitespace character, an empty space or \" \". If possible, please provide a Java example.

For example: String

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 05:48

    You can use charAt() function to find out spaces in string.

     public class Test {
      public static void main(String args[]) {
       String fav="Hi Testing  12 3";
       int counter=0;
       for( int i=0; i

提交回复
热议问题