String

     void main(){
          String str1 ='hello';
          String str2 ='''hello dart''';
          String str3 ='hello \n dart';
          String str4 =r'hello \n dart';
          String str5 ='Go  go  go';

          int a = 1;
          int b = 2;
          print('a+b = ${a + b}');
          print(str2);
          print(str3);
          print(str4);
          print(str5 +'qianqian');
          print(str5 *5);
          print(str4 == str5);
          print(str5[0]);
          print(str5.length);
          print(str5.isEmpty);
          print(str5.contains('G'));//是否包含
          print(str5.substring(0,2));//截取前两个字符
          print(str5.startsWith('a'));//是不是以a开头的
          print(str5.endsWith('o'));//是不是以a结尾的
          var list = str5.split(" ");//分割字符串
          print(list);
   }

20200806132401.png

Last modification:August 6th, 2020 at 01:34 pm
如果觉得我的文章对你有用,请随意赞赏