list

  void main(){
    var list1 = [1,2,3,"dart",true];
    print(list1);
    print(list1[1]);
    list1[1] = 'hello';
    print(list1);
    var list2 = const [1,2,3];
    print(list2);
    var list3 = new List();
    var list = ['hello','dart'];
    print(list.length);
    list.add('new');//list 添加
    print(list);
    list.insert(1, 'java');//list 插入
    print(list);
    list.remove('java');//list 移除
    print(list);
    print(list.indexOf('dart'));
    list.sort();//list 排序
    print(list);
    print(list.sublist(1));//list 截取掉索引值是1的
    list.forEach((print));
  }

20200806132925.png

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