First, Collection Framework and generics
- 1. definition
A collection frame is used to store a set of elements that are variable in length.
- 2. common interfaces and classes
Interfaces: Collection, List, Set, Map, Iterator
Classes: ArrayList, LinkedList, HashSet, HashMap
Both the list interface and the set interface inherit from the collection interface.
- 3. Usage features
List: The stored elements are not unique and orderly.
Set: The stored element is unique and unordered.
MAP: Elements are stored in the same way as key-value pairs.
- 4. The difference between ArrayList and linkedlist
ArrayList: Find elements fast, high performance, but not suitable for frequent insertion, modification, deletion of collection elements.
LinkedList: High efficiency and speed when inserting, modifying and deleting collection elements frequently, but not as fast as ArrayList.
- 5. Common Methods of collection:
List:
Add (Object obj), remove (object obj), remove (int index), size (), get (int index), iterator (), clear ()
Set:
Add (Object obj), remove (object obj), size (), iterator (), clear (), no get method
MAP:
Put (object key, Object value), get (Object key), KeySet (), values (), size (), remove (object key), clear ()
Second, Practical Class
- 6. Enumeration
Definition: A fixed set of constants.
Grammar
Access modifier enum enum name { Constant One, Constant Two, ... ... } |
Usage
Declare the enumeration variable and assign the value: Season Season = season.spring;
Switch
Switch (enumeration variable) { Constant one: ... ... break; Constant two: ... ... break; } |
- 7. Packing class
There is a corresponding wrapper class for each value type (base data type).
Int->integer, Double->double, Boolean->boolean, Char->charactor 、... ...
Mutual conversions of value types and wrapper classes
Unpacking and boxing
Boxing: Converts a value type to a reference type.
Unboxing: Converts a reference type to a value type.
- 8. Math class
The role of the math class
Provides a range of methodologies related to scientific calculations.
Common methods: Random (), floor (), ceiling (), Max (), Min (), round ()
- 9. String class
Common methods: substring (), indexOf (), lastIndexOf (), replace (), split (), Length ()
- Random class
Function: Generates a random number.
Common methods: Nextint (), nextint (int), nextdouble (), nextxxx ()
- One . Date Time class
Date
Calendar
SimpleDateFormat
- What is the difference between StringBuilder (StringBuffer) and String ?
When a String is in operation (such as assignment, stitching, and so on) a new instance is generated, and StringBuilder does not. So it's best to use StringBuilder (StringBuffer) When a large number of string concatenation or frequent manipulation of a string, and do not use string.
Third, Input/Output IO
IO operation-related packages: java.io
- File class
Functionality: Implements general operations on files and directories.
Common methods:
Method name |
Role |
Exits () |
Determine if a file or directory exists |
|
|
|
|
- Classification of streams
Classification by direction:
Input: InputStream, Reader
Output: OutputStream, Writer
Classification of data units based on flow operations:
BYTE stream: InputStream, OutputStream
Character stream: Reader, Writer
Implementation class
(pump) inputstream |
(pumping) OutputStream |
(draw) Reader |
Writer |
FileInputStream |
FileOutputStream |
InputStreamReader |
OutputStreamWriter |
DataInputStream |
DataOutputStream |
FileReader |
FileWriter |
ObjectInputStream |
ObjectOutputStream |
BufferedReader |
BufferedWriter |
Serialization and deserialization
Serialization refers to the process of converting the state of an in-memory object into a format that can be stored or transmitted.
Four, Multithreading
- The differences between processes and threads
A running instance of an executable program in a computer is a process. A process can contain multiple threads. A single thread is used to complete a task, while creating multiple threads to accomplish multiple tasks is multithreaded.
Both define a boundary, but the process defines the boundary between the application and the application, and the code and data space cannot be shared between different processes, and the thread defines the boundaries of the code execution stack and execution context.
In a metaphor, if a family represents a process, within the family, each member is a thread, and each member of the family has an obligation to accumulate the wealth of the family, while also having the right to consume the household wealth, and when confronted with a task, the family can also send several members to cooperate to complete, People outside the family have no way of directly consuming property that does not belong to their own family.
- steps to using threads in Java
- 2 ways to define threads in Java
- Priority of Threads
- The life cycle of a thread
- synchronization of Threads
- . Thread Common methods
Five, Network Programming
- What is TCP and UDP, and what are their differences?
TCP (transmission Control Protocol, transmission Protocol) is a connection-based protocol, which means that a reliable connection (trust connection) must be established with the other party before the data is formally sent and received.
UDP (User data Protocol, Subscriber Datagram Protocol) is the protocol that corresponds to TCP. It is a non-connected protocol that does not establish a connection with the other, but sends the packet over directly!
UDP is suitable for applications that transmit small amounts of data at a time and are not highly reliable, but transmit at a fast speed.
TCP is suitable for transmitting a large amount of data at a time, high reliability requirements of the environment, data transmission speed is slow.
Six, XML Operation
- the basic concepts of XML
XML to extend markup language. Typically used to store data and transfer data between networks.
XML is much like Hypertext Markup Language (HTML), but it does not specify which tags are intrinsic.
The XML usage specifications broadly include:
The first behavior XML declaration for each XML file, which defines information such as the XML version and encoding.
An XML document has and has only one root node.
The XML is case-sensitive.
Each XML tag must contain a start tag and an end tag.
The XML tag must be properly absconded.
- The main differences between XML and HTML
XML is used to store and transfer data, while HTML is used to display data.
XML distinguishes between uppercase and lowercase letters, while HTML is not.
The opening tag of the HTML can have no closing tag, and the opening tag of the XML must correspond to the closing tag.
In XML, attribute values must be enclosed in quotation marks. In HTML, the quotation marks are available for use.
You can have a property name without a value in HTML. However, in XML, all attributes must have corresponding values.
tags in XML can be customized by the user, while HTML contracts which tags can be used.
- What are the techniques for manipulating XML in JAVA
Dom Mode
The DOM is the standard API for processing XML, and it is the basis for many other standards related to XML processing. It operates based on the relationships between nodes in the XML document, and the biggest problem is that the entire XML document needs to be loaded into memory at once.
Sax
SAX fundamentally solves the resource-intensive problems that DOM produces when parsing XML documents. It is implemented through a stream-like parsing technique that reads through the entire XML document tree and responds to the programmer's need for XML data parsing through an event handler.
dom4j
DOM4J is an easy-to-use, open-source library for Xml,xpath and XSLT. It is applied to the Java platform, implemented with the Java Collection framework, and fully supports Dom,sax and JAXP.
- What is XPath
An XPath is an XML Path Language (XML pathname Language), which is a language used to determine the location of a part of an XML document. XPath is an XML-based tree structure that provides the ability to find nodes in a data structure tree.
An expression |
Description |
Example |
NodeName |
Select all child nodes of this node |
Bookstore () |
/ |
Select from the root node |
/bookstore (select root element Bookstore) |
// |
Selects a node from the matching current node, regardless of location |
Book selects all book child elements, regardless of their location |
. |
Select the current node |
|
.. |
Select the parent node of the current node |
|
@ |
Select Properties |
@lang Select All properties named Lang |
Java Advanced Stage Knowledge point Rollup