List It's an ordered set , So you can see that arrays are also collections , The difference between them is in the length of the array , and List You don't need to .
The definition of set is very simple

ArrayList And vector They're all ordered sets , Allow repetition , In general, the ordered collection is used in the case of multithreading vector, Because it ensures thread safety .
List l=new ArrayList();
ArrayList Provided add\remove And so on
l.add(" Zhang "); l.add(" king "); l.add(" Zhao ");
But if I mix in here and add some int It's also allowed
l.add(" Zhang "); l.add(" king "); l.add(" Zhao "); l.add(3);
But it doesn't make sense , We have to constrain types to make sense
List<String> l=new ArrayList(); l.add(" Zhang "); l.add(" king "); l.add(" Zhao "); l.add(3);
// This will not compile , Because it's already constrained for String;
Ergodic collective method 1( This method is not recommended ):for
for (int i = 0; i <l.size() ; i++) { System.out.println(l.get(i)); }
Ergodic collective method 2( recommend )Iterator
List<String> l=new ArrayList(); l.add(" Zhang "); l.add(" king "); l.add(" Zhao "); for(
Iterator<String> it= l.iterator();it.hasNext();){ System.out.println(it.next());
}
Ergodic collective method 3( recommend )for each The cycle becomes Iterator Call of
for (String s:l ) { System.out.println(s); }
ArrayList It is generally used in single thread ; and vector It's used the same way , But it's not as efficient as it is , However, thread safety is generally used in multithreading .

Technology
©2019-2020 Toolsou All rights reserved,
One is called “ Asking for the train ” A small village Finally got the train Spring Boot Lesson 16 :SpringBoot Implementation of multithreading with injection class Chrome OS, For programmers and Windows What does it mean ? Internet Marketing JAVA Convert a string to a numeric type I've been drinking soft water for three years ? What is the use of soft water and water softener You don't know ——HarmonyOS Talking about uni-app Page value transfer problem JavaScript Medium Call and ApplySparkSQL Achieve partition overlay write Character recognition technology of vehicle license plate based on Neural Network