Java Learning (11)

Source: Internet
Author: User
Tags time in milliseconds

Common class systems related class System class

The System class is a final class, and all properties and methods of the class are static. The properties of the system class in, out, and err correspond to standard input, standard output, and error output stream, respectively. The system class is often used to log program execution time, copy arrays, determine current system properties, and get system environment variables-Currenttimemillis () returns the current time in milliseconds. Starting from 1970/1/1 to the present

    • Exit (int status) terminates the currently running Java Virtual machine
    • GetProperties () Determining the current system properties
    • GetProperty (String key) Gets the system properties for the specified key prompt
    • Nanotime () returns the current value of the most accurate available system statistic timer, in milliseconds
    • GC () Garbage collector

Many algorithms are used in garbage collection mechanism: Reference counting algorithm, search algorithm, copy collection algorithm, tag elimination algorithm, tagging algorithm, etc.

Runtime class

The runtime class represents the Java program Runtime environment, and each Java program has a runtime instance associated with it, which is connected to its runtime environment by the application. The application cannot create its own runtime instance, but the runtime object associated with it can be obtained through the static method GetRuntime () of the runtime class

Once the runtime object is acquired, it can be used to access information about the JVM, the number of processors, and the associated methods. Memory information, etc.

String-related classes
    • String class

The string class contains an immutable character Hello string, String str=new String(“hello”) or when the same type is stored, the same String str=“hello” memory address "= =" is the memory address comparison

The string class provides a number of methods for manipulating the string object. See API

    • StringBuffer class

The StringBuffer object represents a variable string, and when a stringbuffer is created, it is possible to change the character sequence of the string by his method. Once the desired string is produced, you can call the ToString () method to convert it to a String object method as described in the API

    • StringBuilder class

JDK1.5 a new object, which also represents a string object. It is the same as string and stringbuffer in many ways, but it is thread-safe. Builder is a lightweight version of buffer for better performance

Performance: buider>buffer>string

Generally use string, often modified with buider or buffer

Java Learning (11)

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.