1  List list = new ArrayList
2 list.add("张三");
3 list.add("李四");
4 System.out.println("list对象输出"+list+" ,list字符串输出"+list.toString());
5 控制台打印输出结果:list对象输出[张三, 李四] ,list字符串输出[张三, 李四]

 

1  //判断 list字符串中是否含有张三
2 System.out.println("list字符串中是否含有张三"+list.contains("张三"));
3 控制台打印输出: list字符串中是否含有张三true

 

1  //判断list对象是否有null或有长度不能[]
2 System.out.println("list字符串中是否含有张三"+list.isEmpty());
3 控制台打印输出:false 因为有张三和李四




 

相关文章:

  • 2022-12-23
  • 2021-03-27
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-11-28
  • 2021-04-15
  • 2022-02-23
猜你喜欢
  • 2022-12-23
  • 2021-07-29
  • 2021-09-30
  • 2021-10-19
  • 2022-12-23
  • 2021-04-04
  • 2022-12-23
相关资源
相似解决方案