What is the principle of Java Linked list
This article introduces the relevant knowledge of "what is the principle of Java Linked list". In the operation of actual cases, many people will encounter such a dilemma. Then 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!
Definition: linkedlist belongs to the linked list structure, which is convenient to add and delete elements, but the query is not convenient, so it is suitable for the closing operation.
With a specific object, use the object to call the specific method
Add
/ / add element / / add element arr.add ("H") in the middle
AddFirst: add elements to the front of the collection
/ / add element arr.addFirst ("F") to the header of the linked list
AddLast: add elements to the end of the collection
/ / add the element arr.addLast ("L") to the end of the linked list
RemoveFirst removeLast: delete the first element, delete the last element
/ / Delete element arr.removeFirst ()
GetFirst getLast: get the first element, get the last element
/ / get the element String s1=arr.getLast ()
IsEmpty: used to determine whether there are elements in the collection. If so, false is returned.
Pop: pops elements from the collection from the stack
/ / when there is an element in arr, return False, use! Reverse while (! arr.isEmpty ()) {/ / pop the data in the array out of System.out.println ("this is the pop method" + arr.pop ());}
Push: add elements to the collection
/ / add new data arr.push ("xin") to the array
This is the end of the content of "what is the principle of 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!