Data structures in Java

Source: Internet
Author: User
Tags bitset

The following is referenced from http://wiki.jikexueyuan.com/project/java/data-structures.html:

The data structure provided in the Java Toolkit is very powerful and has a lot of functionality. These data structures contain the following interfaces and classes:

    • Enumeration
    • BitSet
    • Vector
    • Stack
    • Dictionary
    • Hashtable
    • Properties

Now that these classes are old, Java-2 has introduced a new framework called the collections framework.

First, enumeration

The enumeration interface itself is not a data structure, but it is very important in other data structures. The enumeration interface defines a method for successive acquisition of elements from a data structure.

For example, enumeration defines a method called Nextelement that can be used to get the next element in a data structure that contains many elements.

Second, BitSet

The Bitset class implements a set of bits or flags that can be set and purged independently.

This class is useful when you need to save a set of Boolean values, and you only need to assign a bit to each value or collection and set or clear it as appropriate.

Third, Vector

The vector class is similar to a traditional Java array, but it can add new elements.

As with arrays, the elements of a vector object can be accessed by the subscript ordinal.

For the use of the vector class, it is good to not worry about setting a particular collection size when it is created, and it can automatically shrink and expand when necessary.

Iv. Stack

Element last in, first out (LIFO) in the Stack class.

It is simple to assume that a stack is a vertically stacked object, and when a new element is added, it is at the top of other elements.

When an element is moved out of the stack, it is moved out from the top of the stack. In other words, the last element of the add-on stack is removed first.

Wu, Dictionary

The dictionary class is an abstract class that defines a key-value pair that maps this data structure.

The dictionary class is best used when you want to access data through a special key rather than through an integer subscript.

Because the dictionary class is abstract, it provides only a key-value pair of mapped data structure frames rather than a concrete implementation.

Liu, Hashtable

The Hashtable class provides a way to organize your data, depending on some user-defined keys.

For example, in a hash table of an address list, you can rely on a key like zip code to store and sort data instead of relying on a person's name.

The special meaning of the key in the hash table depends entirely on the purpose of the hash table and the data it contains.

Seven, the Properties

Properties is a subclass of Hashtable. It is used to contain a list of values in which the key is a string and the value is also a string.

The properties class is used by many other Java classes. For example, when you get the value of an environment variable, it is the object type of the System.getproperties () method that returns the value.

Data structures in Java

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.