Set learning notes, set learning notes
I. Concepts
A set is a way to store objects. The collection contains addresses for convenient reference. JDK 1.2 is available.
Ii. Differences between a set and an array
Set is variable length, and array is
The rest will not be said. Everything is in the code.
Package com. gc. generic;/*** usage of collection objects before JDK5: * 1. Add any type objects to the Collection * 2. data types are lost when an object is retrieved from the collection, use
Iterator Mode
Provides a method to access each element of an aggregate object sequentially without exposing the internal representation of the object.
Package com. ruishenh. designPatter. action. iterator; import java. util. arrayList; import
The ITERATOR mode (ITERATOR), also known as Cursor, provides a method for sequentially accessing each element of an aggregate object without exposing the internal representation of the object, it belongs to the object behavior mode. The iterator
1. Read and parse the XML document:SAXReader reader = new SAXReader ();Document document = reader. read (new File (fileName ));Reader's read method is overloaded and can be read from multiple sources, such as InputStream, File, and Url. The
[Switch] parse json data for Android and parse json data for android
1. json format2. json parsing 3. gson parsing 4. fastjson parsing 1. Json format a lightweight data exchange format. Xml and json are generally used for data transmission and
Create a pattern1. Factory method Mode (Factory Methods) the operation of creating objects in the program is processed separately, creating a factory interface for the product and transferring the actual work to the detailed subclass. The
1 Synchronous Method VS Synchronous code block:In Java, each object has a lock, and the thread acquires the lock on the object with synchronized.Non-static synchronization method: A lock is a lock on an object of a class.Static Synchronization
Topic:Implement an iterator over a binary search tree (BST). Your iterator is initialized with the root node of a BST.Calling would return the next smallest number in the next() BST.Note: next() hasNext() and should run in average O (1) time and
The Java Collection Framework provides the following two types of containers: 1, Collection (Collection): Access a collection of individual elements. 2. Figure/Map (map): Store key/value pairs (key-value).Collection interface and Abstractcollection
Original works, can be reproduced, but please mark the source address: http://www.cnblogs.com/V1haoge/p/7229478.html1. OverviewJava's collection Class library is very rich, encompassing most of the common data structure forms, allowing us to have a
------------I do not have him, but the hand is ripe, humble and foolish, and eager to be hungry-------------First from the conceptual understanding, from the central scheduler, carrying the parameter request, dispatching to the Handlemapping
[Copy question]:Given a nested list of integers, implement an iterator to flatten it.Each element was either an integer, or a list--whose elements may also be integers or other lists.Example 1:Given the list [[1,1],2,[1,1]] ,By calling next
1, Java's initial version provides a very small set of classes for the most commonly used data structures: Vector, Stack, Hashtable, Bitset, and enumeration interfaces, starting with the JAVA1.2 release of a set of fully functional data
The concept of generics:Simply put, it is the same method (class) that can accept different data types and run the corresponding results without security issuesThe previous article has a code like this:No collection type defined, iterator type
OverviewJava allows us to define a class A in another Class B, then this class A is called an inner class. such as the following:
If the interior is similar to non-static, it is called an inner classclass OuterClass { ... class NestedClass {
Definition: provides a way to access the elements of a container object without exposing the internal details of that object.Type: behavior class patternclass Diagram:
If you want to ask one of the most used patterns in Java, the answer is not a
Take a look at the iterator pattern today.
When it comes to iterators, a bit of programming experience should know iterator. Yes, this is the iterator.
Sometimes in the process of taking a loop, we usually get the iterator in the container and loop
Introduction
Any container, there must be some way to insert the elements and retrieve them again. For the list container, add () is one of the methods to insert the element, and get () is one of the methods for fetching the element. To use a
Here all the screenshots of the source code from JDK8
Look at a picture
First look at the basic interface of the collection class: Collection, which inherits the Iterable interface.
Look at the source of the time found this interface, since there
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.