Dark Horse programmer Java Learning diary java-Other types

Source: Internet
Author: User

OK, ready, first blog open ~

Android training, Java training, look forward to communicating with you!

First listen to the other types of passion, grandpa, starting from here:

A System class

The System class represents a class of systems, and the properties and methods of the system are placed in that class. The System class is a final class that cannot be initialized, that is, the properties and methods in the system class are static and can be called directly. The system's member variables are out,in, err is standard input output and error input (stream), and the system class is commonly used in the following ways:

A. Arraycopy method: public static void Arraycopy (object src, int srcpos, object dest, int destpos, int length)

The function of this method is to copy the array, that is, the contents of one array to the specified position in another array, because the method is the native method, so the performance is more efficient than the use of loops.

B. Currenttimemillis method: public static long Currenttimemillis ()

The function of this method is to obtain the current time of the system.

C. Exit method: public static void exit (int status)

The function of this method is to exit the program. Where status has a value of 0 for normal exit, not 0 for abnormal exit. By using this method, the program Exit function can be realized in the programming of graphical interface.

D. GetProperty method: public static string GetProperty (String key)

    The function of this method is to obtain the value corresponding to the attribute named key in the system.

Two Runtime class

The runtime class represents a runtime action class, a class that encapsulates a JVM process, each of which corresponds to an instance of a runtime class that is instantiated by the JVM runtime. The runtime class is not constructed because the runtime class itself is privatized (singleton design), and if you want to get a runtime instance, there are only the following methods:

Runtime Run=runtime.getruntime ();

In other words, a static GetRuntime () method is provided in the runtime class, which can obtain an instance of the runtime class and then obtain some system information through runtime. For example, GetRuntime (), gets the runtime instance, Freememory () returns the amount of idle memory in the Java Virtual machine, maxmemory () returns the maximum amount of memory for the JVM, and exec executes the native command.

Three Process class

  The process class is an abstract class, and all of its internal methods are abstract, and theruntime.exec () method can create a local process and return an instance of the process subclass. The method of creating a process may not work well for specific processes on some native platforms, such as native window processes, daemons, win16/dos processes on Microsoft Windows, or shell scripts. The child process created does not have its own terminal or console. All of its standard IO (i.e., stdin, stdout, and STDERR) operations are redirected to the parent process through three streams (Getoutputstream (), getInputStream (), and Geterrorstream ()). The parent process uses these streams to provide input to the child process and to obtain output from the child process. Because some native platforms only provide a limited buffer size for standard input and output streams, it can cause child processes to block and even deadlock if the output stream or input stream of a child process fails quickly. To kill a subprocess, the Destroy () method of the process is required.

Four Date class

  DateRepresents a specific moment, accurate to milliseconds. It allows you to interpret dates as year, month, day, hour, minute, and second values. It also allows formatting and parsing of date strings. SimpleDateFormat formatting the date class.

SimpleDateFormatis a specific class that formats and resolves dates in a language-related way. It allows formatting: (date-and text), parsing (text-to-date), and normalization.

Five Math class

The math class is also a final class that can invoke its properties and methods without instantiating the class, because they are static. See the following code for the Math class common methods:

1  Public classMathdemo {2      Public Static voidMain (String args[]) {3         /**4 * ABS seek absolute value5          */6System.out.println (Math.Abs (-10.4));//10.47System.out.println (Math.Abs (10.1));//10.18         9         /**Ten * Ceil ceiling means to return a large value, note some special values One          */ ASystem.out.println (Math.ceil (-10.1));//-10.0 -System.out.println (Math.ceil (10.7));//11.0 -System.out.println (Math.ceil (-0.7));//-0.0 theSystem.out.println (Math.ceil (0.0));//0.0 -System.out.println (Math.ceil (-0.0));//-0.0 -          -         /** + * floor meaning is to return a small value -          */ +System.out.println (Math.floor (-10.1));//-11.0 ASystem.out.println (Math.floor (10.7));//10.0 atSystem.out.println (Math.floor (-0.7));//-1.0 -System.out.println (Math.floor (0.0));//0.0 -System.out.println (Math.floor (-0.0));//-0.0 -          -         /** - * Max Two returns a large value, min and it instead, it's not an example. in          */ -System.out.println (Math.max (-10.1,-10));//-10.0 toSystem.out.println (Math.max (10.7, 10));//10.7 +System.out.println (Math.max (0.0,-0.0));//0.0 -          the         /** * * Random gets a number greater than or equal to 0.0 less than or equal to 1.0 $          */Panax NotoginsengSystem.out.println (Math.random ());//0.08417657924317234 -System.out.println (Math.random ());//0.43527904004403717 the          +         /** A * Rint rounded, return double value the * Note that an even number will be taken at 5. +          */ -System.out.println (Math.rint (10.1));//10.0 $System.out.println (Math.rint (10.7));//11.0 $System.out.println (Math.rint (11.5));//12.0 -System.out.println (Math.rint (10.5));//10.0 -System.out.println (Math.rint (10.51));//11.0 theSystem.out.println (Math.rint (-10.5));//-10.0 -System.out.println (Math.rint (-11.5));//-12.0WuyiSystem.out.println (Math.rint (-10.51));//-11.0 theSystem.out.println (Math.rint (-10.6));//-11.0 -System.out.println (Math.rint (-10.2));//-10.0 Wu          -         /** About * Round rounding, float returns int value, double returns Long value $          */ -System.out.println (Math.Round (10.1));//Ten -System.out.println (Math.Round (10.7));// One -System.out.println (Math.Round (10.5));// One ASystem.out.println (Math.Round (10.51));// One +System.out.println (Math.Round (-10.5));//-10 theSystem.out.println (Math.Round (-10.51));//-11 -System.out.println (Math.Round (-10.6));//-11 $System.out.println (Math.Round (-10.2));//-10 the     } the}

Dark Horse programmer Java Learning diary java-Other types

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.