In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
In this issue, the editor will bring you about what are the common methods of java list. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1.list intercepts the specified part
List sublist = new ArrayList (); sublist = new ArrayList (alist.subList (2,4))
two。 Update content at the specified location
Public ArrayList attrs = new ArrayList (); / / layer attribute attrs.set (position, "string")
3. Determine if there are duplicates in the Arraylis
Public static void main (String [] args) {List list = new ArrayList (); list.add ("aa"); list.add ("bb"); list.add ("cc"); list.add ("dd"); list.add ("bb"); list.add ("ee"); list.add ("dd"); list.add ("ff"); String temp = ""; for (int I = 0; I < list.size ()-1; iTunes +) {temp = list.get (I) For (int j = I + 1; j < list.size ()) {if (temp.equals (list.get (j) {System.out.println ("th" + (I + 1) + "repeat with" + (j + 1) + ", the value is:" + temp);}}
Mutual Transformation between list and Array in 4.java
1) convert an array to a collection
Arrays can be converted to List, but other functions cannot be used except for display functions, because the list obtained through the conversion does not know what type it is, and can be assigned by the construction method of the collection to use other functions:
String [] names = {"Liu Bei", "Cao Cao", "Zhuge Liang"}; List list1 = Arrays.asList (names); list1 = new ArrayList (list1)
2) convert the collection to an array
Object [] ary1 = list3.toArray (new String [list3.size ()]); / / System.out.println (Arrays.toString (ary1))
Convert 5.Hashmap to arraylist
HashMap hashMap = iMarkerService.getBaiduMarkerMap (); ArrayList markers = new ArrayList (hashMap.values ())
6. Convert to the string join
List userParms=new ArrayList (); String userSql = String.join ("AND", userParms)
7. Sort
Collections.sort (warnRes, new Comparator () {/ / sort by final insurance date public int compare (WarnRes warnRes0, WarnRes warnRes1) {return warnRes1.getZbrq () .compareTo (warnRes0.getZbrq ());}})
These are the common methods of java list shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.