list中的contains:是否包含指定元素

list中的SubList:  返回列表中指定的 fromIndex(包括 )和 toIndex(不包括)之间的部分视图。

List<String> addlist = new ArrayList<String>();
		addlist.add("hello");
		addlist.add(0, "hi");
		addlist.add("world");
		addlist.add("welcome");
		addlist.add("how");
		
		//是否包含指定元素
		System.out.println( addlist.contains("hi") );
		//是否包含指定元素
		System.out.println( addlist.contains("how") );
		
		//返回列表中指定的index(包括)和endIndex(不包括)之间的数据
		System.out.println( addlist.subList(0, 2) );
		//返回列表中指定的index(包括)和endIndex(不包括)之间的数据
		System.out.println( addlist.subList(2, 5));
		

  

 

相关文章:

  • 2022-02-13
  • 2021-05-21
  • 2021-09-05
  • 2021-05-04
  • 2021-04-30
  • 2021-09-24
  • 2021-11-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-19
  • 2021-11-01
  • 2021-08-09
  • 2021-11-18
  • 2021-06-08
相关资源
相似解决方案