Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Java linked list

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to realize the Java linked list". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Hash table = array () + linked list (slow query, quick additions and deletions)

two。 Use a loop with break, or you'll end up in a dead loop.

3. If you keep looping to make judgments, you will nest if judgment statements in while.

4. Introduce a third party as an intermediary to solve the problem (the role of markers), previous,next,last

5. Implementation of linked list (HashMap)

1.public class Node {one node on Node previous;// Node next;// next node Object element;// customizes a linked list 2.public class ListNode1 {public Node first;// first node public Node last;// last node public int size;public void add (Object obj) {Node node=new Node (obj); if (first==null) {first= node; last = node } else {node.previous=last; node.next=null; last.next=node; last=node;}

Related diagrams

Description: the essence is to copy a copy of node1 into last, and when node02 comes to last to get it, it takes the data of node1, with the help of last, so as to link node1 and node2 together.

This is the logical diagram of adding nodes to the hash table.

6.treemap (red-black tree), which can achieve the function of sorting. (you can customize to sort according to an item)

7. Storing an object in a file is serialization, and restoring an object is deserialization.

8.IO streams (divided into byte streams (int) and character streams (string))-both inflows and outflows are int centered on the java program.

Step: 1. Create Source, 2. Select a stream (for example, there are many types of input streams). 3. Operation (read or fetch) 4. Close the stream. [the four most critical steps]

String str=new String (car,0,len); / / changes from byte array car to string. Decode (used in the input stream). String msg= "IO is easy" byte [] data=msg.getBytes () / / converts a string to a byte array (encoding)

Bytes (byte), characters (char) FileInputStream (stored on hard disk) vs BytesInputStream (stored in memory)

1. Byte stream (dealing with pictures, videos, if for text, use char conversion to display characters) vs character stream (underlying) (processing text)

two。 It's best to use flush () to force a refresh when writing out, because it has a buffer stream.

3. Multiple streams are nested together-buffered streams are nested in decorative streams, and node streams are nested in buffered streams. The node flow is the core.

4. If you don't understand, look here (copy of the file)

This is the end of the content of "how to implement the Java linked list". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report