Java data structure (1)

zhaozj2021-02-16  80

Java is a very complete programming language that has a very safe grammatical definition, fully facing the object's programming idea, it is more difficult to have a very powerful API. Today, let's take a look at the data structure predefined in Java. Some people mentioning the data structure have a terrible association. Indeed, some operations for complex data structures are very headaches, I have some hope to have some expectations. But it is very convenient to operate in Java. Because it is not only defined in Java, it is defined to be customized, but even various operations are defined into methods that can be directly called. All predefined data structures of Java are placed in the Util package, and import java.util. *; This can be used in the code. Let's take a look at the Vector class. The vector is translated into "vector", and we will call it like this. The vector is actually a dynamic array, which can be added, delete members. Please see the example below: Import java.util. *; Public class usvector extends vector {

Public USEVECTOR () {addElement ("tom"); addelement ("jim"); addelement ("jack");} public object get (int index) {return super.get (index);} public static void main (String [] args) {system.out.print (new useportctor (). get (1));}} This example output is: JIM Here we should pay attention to the vector to add members to Object store, so we When you take out the element, you should force the converted to the original type, you should write: (String) New usevector (). Get (1); but we just have to output a string, so there is no clear writing, in fact it is Implicit conversion into a string. Let's take another example: Import java.util. *; Public class usvector extends vector {

转载请注明原文地址:https://www.9cbs.com/read-17265.html

New Post(0)