Java Common classes:
- Java.lang Package:
- Java.lang.Object class :
- Hashcode () Method: Returns a hash code for an integer representing the address.
- ToString () Method: Returns the parent class name + "@" + hash code (typically used for overwriting).
- Equals () Method: Returns the Boolean value of the "= =" operation (typically used for overwriting).
- Finalize () method: Used for object destruction (not controlled by the JVM, called by the JVMs, followed by garbage collection mechanism).
- Clone () method: used for copying between objects (deep copy).
- GetClass () Method: Returns the object's bytecode file object (typically used for reflection technology).
- java.lang.String class : The string has been created and the content is immutable, just a process of constantly creating a new string.
- Concat () Method: The connection operation of the string.
- SUBSTRING () method: The Intercept operation of the string.
- Trim () Method: Remove the leading and trailing spaces.
- Length () Method: Returns the length of the string.
- GetBytes () Method: Returns a string corresponding to the bytes array, which can be entered in the specified character set for decoding.
- Matches () method: You can use regular expressions to determine whether a given string conforms to a regular expression and returns a Boolean value.
- Replace () Method: string substitution.
- ReplaceAll () Method: regular substitution.
- Replacefirst () method: The first matched string is replaced with a regular one.
- Split () method: The string is split in a regular fashion .
- Java.lang.StringBuffer class: Thread-safe string classes are more efficient than string.
- Append (), insert (), delete (), length (), reverse (), replace (), substring () and other methods
- Java.lang.StringBuilder class: Ditto, but thread insecure, more efficient than stringbuffer.
- Java.lang.Math class : Provides methods for mathematical operations, as well as a constant encapsulation of E and pi.
- Java.lang.Thread class : You can implement multithreaded programming by inheriting this class and overriding the appropriate methods.
- Java.lang.System class: In addition to some of the same methods as the runtime class method, there are key standard input and output streams and error streams in, out, err.
- Java.lang.Runtime class: Includes a number of virtual machine methods, GC (), exit (), and so on.
- Java.lang Package class that contains all the basic data types in the core package: (Boolean, Byte, short, Integer, Long, Character, Float, Double)
- 2. Java.util Package:
- Java.util.Random class: Generates a Random object, and then calls the next () method to generate an arbitrary number. The principle of Generation: linear with congruential and Rn = (a*rn-1 + b)%M [M is range, R0 is seed, initial value]. It is also common to use Math.random () multiplied by a certain number of multiples to generate a range of random numbers.
- Java.util.Collection Interface: Represents the root interface of all collections, and abstracts some methods such as add (), remove (), iterator (), size (), which should be implemented by the collection. There are many sub-interfaces under this interface, such as list, set, queue and other sub-interfaces, respectively, representing ordered sets, unordered sets and queues.
- Java.util.List Interface : contains ArrayList, LinkedList, Vector, and other implementation classes, with the addition of the set () and get () methods.
- ArrayList class: most efficient, most commonly used, but not synchronous, thread insecure, allow element to be null. The can be ArrayList object thread-safe through the Collections.synchronizedlist () method.
- LinkedList class: has many convenient ways to tail-and-kinsoku because it inherits the interface of the queue.
- Vector class: An array of objects that can grow, which can only hold objects. is thread-safe.
- Java.util.Set Interface : unordered list, no duplicates are allowed, but you need to override the Hashcode () method and the Equals () method to determine whether the elements are equal. contains HashSet, Linkedhashset, TreeSet and other implementation classes.
- HashSet class: The use of hash table data structure implementation (essentially the HASHMAP implementation of the bottom), to facilitate the search. duplicate, unordered, allowed and only one null element is not allowed, and thread is unsafe.
- Linkedhashset class: Combines hash tables and linked lists, allowing elements to be arranged in an orderly manner. thread is not secure.
- TreeSet class: an ordered tree structure to store data, which can be sorted by TreeSet, but it needs to be passed into the comparer in the constructor, implementing the CompareTo () method and the Equals () method. Thread is not secure.
- Java.util.Queue interface: Contains Arraydeque, Delayedquene, Priorityqueue and other implementation classes, not commonly used.
- Java.util.Map Interface : Represents the root interface of a key-value pair, and defines methods such as put (), get (), EntrySet (), KeySet (), and values () for the operation of many key-value pairs.
- HashMap class: a hash table implements a key-value pair class, unordered, which allows NULL to be used as a key and value, which is out of sync with the class thread.
- Hashtable class: null keys and values are not allowed, unordered, thread safe, but less efficient. Properties inherits the Hashtable class. The key object must implement the Hashcode () method and the Equals () method. The impact of the initial capacity and loading factor determines the execution of the rehash (increased table capacity) operation.
- TreeMap class: Navigablemap implementation based on red and black trees. thread is out of sync, you can implement the CompareTo () method and the Equals () method by passing in the comparer to achieve an orderly arrangement. you can call the Headmap () method and the Tailmap () method directly to intercept a partial map.
- The most important classes in the Java.util package are collection-related classes. for collection, iterator iterator can be used to iterate through the elements. For map, you can get all the key set of the map by keyset (), and then get the corresponding value by the Get () method, or you can get the relationship set between the key and the value by EntrySet (), and then through the Getkey () method and GetValue () method to get the key and value. For vectors and Hashtable you can iterate over elements using the enumeration interface enumeration. The values in the collection cannot be modified during all iterations, or they will be thrown
ConcurrentModificationException异常。
- 3. Java.math Package:
- The BigInteger class and the BigDecimal class are typically used for very large data. Operators cannot be used between objects, only methods can be called to handle them.
- 4. Internationalization-related classes:
- Java.util.Date class: The default constructor represents the current time, and the constructor with the parameter represents the number of milliseconds from January 1, 1970 to the present.
- Many methods are obsolete, leaving only a few methods, most of which are replaced by the Calendar class: GetTime (), before (), after (), CompareTo () method.
- Java.util.Calendar class: An abstract class that can be used by the getinstance () method to obtain an instance of the class.
- Add (), before (), after (), GetTime (), Get (), set () and other methods, and use constants in the class as parameters.
- Java.util.Locale class: Represents the time zone, language, and region.
- The class contains a number of constants that represent the country, as well as methods for obtaining information about the system, such as the Getdefault () method, which can obtain the default locale for the virtual machine.
- Java.text.DataFormat class: Simple Date abstract class, you can get the date instance of the class through the Getdateinstance () method, or you can get an instance of the time through the Gettimeinstance () method, You can select the appropriate date format (constant for the class) by passing in the parameters, and finally, the output of the date is achieved through the object. Format () method. You can also parse the string with the parse () method to get the date object.
- Java.text.SimpleDateFormat class: Inherits the DateFormat class, uses the constructor to obtain the instance, implements the globalization of the date format by passing in the specified date format, and finally implements the output of the date through the object. Format () method. You can also parse the string with the parse () method to get the date object.
Java Foundation--java Common class