First, arrays class
This class contains various methods for manipulating arrays, such as sorting and searching. This class also contains a static factory that allows the array to be viewed as a list.
1. Common methods
Public Static voidMain (string[] args) {int[] arr= {1,5,6,8,3,5,2,4,9}; //converting an int array to a stringString ret=arrays.tostring (arr); SYSTEM.OUT.PRINTLN (ret); //Sort, second to sixth number to sortArrays.sort (arr,2,6); System.out.println (arrays.tostring (arr)); //all books are sorted, from small to largeArrays.sort (arr); System.out.println (arrays.tostring (arr)); //in the specified array, find where the value of the given element appears. If no query is reached, the return position is-1. Requires that the array must be an ordered array. System.out.println (Arrays.binarysearch (arr,6)); }
Second, System class
system, which represents the program, provides the corresponding system property information, and system operation.
1. Common methods
Public Static void Main (string[] args) {//? Gets the millisecond difference between the current system time and the January 01, 1970 00:00 Point long time=system.currenttimemillis (); // can be used to test how long the program is running System.out.println (time); // ? Used to end a running Java program. parameter to pass in a number. Usually incoming 0 is recorded as the normal state, others are abnormal state system.exit (0); System.out.println ("ending");}
Public Static voidMain (string[] args) {//array Copy method in the System class Arraycopy//there is no method body for this method, the method uses the native modifier (local method), and the lower-C + + language is used int[] src={1,2,3,65,6,9}; //system.arraycopy (SRC, Srcpos, dest, destpos, length);//src-source array. //Srcpos-The starting position in the source array. //dest-target array. //Destpos-The starting position in the target data. //Length-The number of array elements to copy. //copies an array from the specified source array, starting at the specified location and ending at the specified position in the destination array. }
Second, the Math class
Math contains methods for performing basic mathematical operations, such as elementary prime numbers, logarithms, square roots, and trigonometric functions, all static methods.
1. Common methods
?//Abs method, the result is positiveDoubleD1 = Math.Abs (-5);//the value of D1 is 5DoubleD2 = Math.Abs (5);//The value of D2 is 5?//The Ceil method, which results in a double value of the smallest integer greater than the value of the parameterDoubleD1 = Math.ceil (3.3);//the value of D1 is 4.0DoubleD2 = Math.ceil (-3.3);//The value of D2 is -3.0DoubleD3 = Math.ceil (5.1);//The value of D3 is 6.0?//The floor method, which results in a double value of the largest integer smaller than the value of the parameterDoubleD1 = Math.floor (3.3);//the value of D1 is 3.0DoubleD2 = Math.floor (-3.3);//The value of D2 is -4.0DoubleD3 = Math.floor (5.1);//The value of D3 is 5.0?//Max method, returns the larger value of two parameter valuesDoubleD1 = Math.max (3.3, 5.5);//the value of D1 is 5.5DoubleD2 = Math.max (-3.3,-5.5);//The value of D2 is -3.3//The min method, which returns the smaller value of the two parameter valuesDoubleD1 = math.min (3.3, 5.5);//the value of D1 is 3.3DoubleD2 = Math.max (-3.3,-5.5);//The value of D2 is -5.5//? Pow method, which returns the value of the second parameter of the first argument to a power ofDoubleD1 = Math.pow (2.0, 3.0);//the value of D1 is 8.0DoubleD2 = Math.pow (3.0, 3.0);//The value of D2 is 27.0//The round method returns the result of rounding the parameter valueDoubleD1 = Math.Round (5.5);//the value of D1 is 6.0DoubleD2 = Math.Round (5.4);//The value of D2 is 5.0//The random method that produces a double decimal that is greater than or equal to 0.0 and less than 1.0DoubleD1 = Math.random ();
Iv. Bigdecimal/biginteger
Neither float nor double can represent precise decimals, at which point the BigDecimal is used to handle the data with high requirements for money and precision
Bigdecimal
Enables high-precision operation of floating-point data
But the data added up is not accurate, so what?
It turns out that this place requires a string type to guarantee the accuracy of the data.
BigInteger
JavainLongType is the largest integer,for more thanLongHow does the type of data be represented?.in theJavain the World,more thanLongInteger cannot be called an integer.,they are encapsulated intoBigIntegerObject.in theBigIntegerin class,implementing arithmetic is a way to implement,not using Operators.
Public Static voidMain (string[] args) {//Big Data Encapsulation for BigInteger objectsBigInteger BIG1 =NewBigInteger ("12345678909876543210"); BigInteger Big2=NewBigInteger ("98765432101234567890"); //Add to implement the addition OperationBigInteger Bigadd =Big1.add (BIG2); //subtract implementing the subtraction operationBigInteger bigsub =big1.subtract (BIG2); //multiply implementing multiplication operationsBigInteger Bigmul =big1.multiply (BIG2); //Divide Implementing Division operationsBigInteger Bigdiv =big2.divide (BIG1);}
Java Foundation 20-system, Math, Arrays, Bigdecimal/integer