Digital Processing class knowledge points

Source: Internet
Author: User

 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

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.