PackageLianxi;ImportJava.util.*; Public classShuzichulilei { Public Static voidMain (string[] args) {//Digital Processing Class//static methods: Methods that do not require class instantiation (new) to be calledSystem.out.println (Math.PI);//the constant of Pi//take an integer Doubled=123.45; //1. RoundingSystem.out.println ("rounding =" +math.round (d));//just look at the first digit after the decimal point//keep several digits after the decimal pointSystem.out.println ("Rounding =" +math.round (d*100)/100.0); //2. Remove limit: The largest integer less than or equal to itSystem.out.println ("Remove limit =" +Math.floor (d)); //3. Take the upper value: the smallest integer greater than or equal to itSystem.out.println ("take the upper value =" +Math.ceil (d)); //random number (only less than 1 of the number)Math.random (); for(inti=0;i<5;i++) {System.out.println ("Random number 1 =" +math.random ()); } System.out.println ("Random number 2 =" +math.random ()); //Random Numbers//instantiation of//random number seed, calculates a certain random number sequence according to the seed valueRandom ran=NewRandom ();//inside the parentheses , the seeds are lost for(inti=0;i<5;i++){ intRan1=ran.nextint (100); System.out.println ("Random number 3=" +ran1+ "+" + (ran1+1));//output range in parentheses } //Data type ConversionsDouble dd=NewDouble ("123.45"); SYSTEM.OUT.PRINTLN (DD); //converting from wrapper class to base type DoubleDV =Dd.doublevalue (); SYSTEM.OUT.PRINTLN (DV); //turn into a stringDouble DF =NewDouble (1234.56); String DS=df.tostring (); System.out.println ("Ds=" +DS); Float F=NewFloat ("123.4"); String FF=f.tostring (); Integer I=NewInteger ("123");//packing class for int intIi=integer.valueof ("1234"). Intvalue (); //Boolean typeBoolean b=NewBoolean ("true");//as long as it is case-insensitive true the output is true, the others are falseSystem.out.println ("boolean=" +B.booleanvalue ()); }}
Digital Processing class knowledge points