hierarchy . Collection represents a set of objects, also known as Collection elements . Some collection allow duplicate elements, while others do not. Some of the collection are orderly, while others are unordered. The JDK does not provide any direct implementation of this interface: it provides more specific sub-interfaces (such as Set and List) implementations. This interface is often used to pass collection and operate these collection where it is required to be the most universal.Collection
TenV.addelement ("AAA"); OneV.addelement ("AAA"); AV.addelement ("abc")); -V.addelement ("CCC"); - the //Traverse - for(Enumeration en =v.elements (); en.hasmoreelements ();) { - System.out.println (En.nextelement ()); - } + - for(Iterator it =v.iterator (); It.hasnext ();) { + System.out.println (It.next ()); A } at } -}Enumeration: It is the predecessor of iterator and can also traverse the collection container.However, b
only three methods in the iteration, one to judge, one to get, the last to delete, and no method to add. The iterator itself has limitations, and the iterator below has sub-interfaces, Listiterator list iterators.The sub-interface provides added methods, modifications, fetches, deletions, and judgments. How do I get a sub-interface object? There is another method in the list collection that is not described, that is, Listiterator (), which can be used to get a list iterator. This iterator, only
. The advantage is that object appears, improve extensibility, but with the drawbacks, is to strong turn. Not strong turn can not be used.Now make some changes to the tool loaded with object in the program, make a change.Write the changes back and forth in a Java tool class, looking up and down. When writing a tool class, this is used to manipulate the object tool class, followed by which object you want to manipulate, not sure. It used to be an objec
ORG.SPRINGFRAMEWORK.WEB.SERVLET.CONFIG.ANNOTATION.ENABLEWEBMVC, @Configuration @enableswagger@enablewebmvcpublic Class Swaggerconfig {private Springswaggerconfig springswaggerconfig; /** * Required to Autowire springswaggerconfig */@Autowired public void Setspringswaggerconfig (Springswagge Rconfig springswaggerconfig) {this.springswaggerconfig = Springswaggerconfig; }/** * Every Swaggerspringmvcplugin bean is picked up by the SWAGGER-MVC * framework
JAVA learning lesson 39th (Common Object API)-set framework (7)-Map set and its subclass object
I. Common subclasses of Map sets
HashTable: the internal structure is a hash table for synchronization. This implementation provides all optional ing operations and does not allow the use of null values and null keys.
(HashTable has subclasses.Properties,Frequently Us
One.Focus on the ArrayList and LinkedList query the reasons for the speed, both additions and deletions have been introduced.The array is a contiguous space, placed in the heap memory, and the elements are placed inside the array.Explain why queries for arrays are fast (all relative) and why the list queries are slow.In heap memory, much of the data is randomly placed, but if a part is stored as an array, it is stored in a corner label. Querying on successive sections is faster than searching in
greater nor less than, is equal to. Then the two elements are the same, the same object, so the Zhouqi is canceled.Some people say that the judgment is one step less, and when the age is judged the same, the name should be judged again.Note that when we write this comparison, we usually rely on the conditions are not unique, called there may be the main conditions at the same time, there are secondary conditions. It is called if the primary condition is the same, continue the comparison on a se
algorithm, and also overrides the Equals method in object, and defines whether the content of its own judgment is the same.Let's take a look at how it's done. Open the source string, outline on the left is the Outline window, which lists all the members of the current class, so it is more convenient to find.Find Hashcode, which shows the string hash algorithm. How it counts, no matter what, it's based on the character of the string itself.The value here is actually the array corresponding to th
JAVA learning lesson 38th (Common Object API)-set framework (6)-Map set and common methods
1. Map set features
The Map set (double row set) adds one element at a time, and the Collection set (single column set) adds one element at a time.Interface Map
Actually, key-value pairs are stored.
Features:
Objects that map keys to values. A ing cannot contain duplic
time is taken according to the person type, because Al2 is placed in the AL1, the time is naturally obtained by AL1. The person can receive student, Mycolleciton This method can accept the new collection to store the E-type element, or the subclass of type E, because there is no problem.take when there is no type of security risks, AddAll method Extensibility is strong, supposedly said to write an e can be, and now expand the sub-class is also possible. When do you use this? When stored, the up
. When I was 1.2, Vetor was included, Vetor was the elder, and it was 1.2 to implement the list, to have the list function, and to be a member of the Java Collection framework. The vetor is synchronous, which means the thread is secure.2. ArrayListThe interior is also an array structure, and is mutable, and is out of sync. Why there is ArrayList, because the Vetor synchronization efficiency is low. Structur
", 11)); Al.add (New Man ("B", 12)); Al.add (New Man ("C", 13)); Al.add (New Man ("a", one));p rintf (AL); Al = Arraylisthashdemo (AL);p rintf (AL); System.out.println (Al.remove (New Man ("a", one)));p rintf (AL); public static ArrayList Arraylisthashdemo (ArrayliSt al) {ArrayList temp = new ArrayList (); Iterator it = Al.iterator (); while (It.hasnext ()) {Object obj = It.next (); if (!temp.c Ontains (obj)) temp.add (obj); return temp;} public static void printf (ArrayList al) {Iterator it = A
(); Jdk1.6offerfrist () offerlast (); JDK1.5 before Getfrist (); Gets the first element (not deleted), if link is empty, throws a Nosuchelementexception exception getlast (); Jdk1.6peekfrist (): Gets the first element (not deleted) if link is empty, return nullpeeklast (); Jdk1.5removefrist (): Gets the first element and deletes if link is empty, throws Nosuchelementexception exception Removelast (): Jdk1.6pullfrist (): Gets the first element and deletes it, If link is empty, return Nullpulllas
, directly printing is a large string, to take out the inside of something difficult to fetch. You can now remove any element by means of an iterator.The use of iterators, first to judge there is no, then a fetch. (now it's all part of the story)What is the other method of extraction?Iterator it is a reference that can be used by it at the end of the while. It.next (); it can not be taken, although it is not available, but it is still in use, in other words, it is in memory.As the iterator ends,
that are most clearly set. Can get the length of the method, no outside length and size. If size is 0, there is no element. The IsEmpty method is true,size if there are elements, the IsEmpty is false. The collection is judged by size, but encapsulated as a isempty. The iterator method that gets the binding element is the iterator. An iterator is a method that is specifically used to remove elements from the collection.The return value of the iterator is very special, not the element being fetc
using object, just write an object, then anything can be solved, now do the qualification, only a part of the type can come in, if not this type or its subclass, then the direct compilation fails. Before it was compiled nothing, run out of trouble.Many of the updates in Java now are run-time errors that go to compile time, which is more secure.The generic type of the qualified knowledge point is specifically written as follows, after qualification, y
,When importing a list package, the list has the name in different packages in Java, and the java.awt package or Java.util package has a list. If the window comes out and returns directly, the java.awt package is imported. In the continuation, the method of invocation is not seen.which element is deleted and which element is returned. Remove can change the length. In order to know more clearly, the light knows to delete a certain corner mark, but also
-defined tool class, the previous example can be used in a different way.The late 1.6 release also provides a number of new methods in the Linklist linked list structure. As shown in.The functions of these methods and the existing methods are the same, but there are some differences, the upgrade is for a reason.The difference needs to know which method is clearly used when developing.GetFirst method has a feature, if there is nothing in the list, call the method, there is no thing. It throws an
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.