Public Static voidMain (string[] args)throwsexception{{//Math function Rounding, attention to negative numbers when the decimal place <=0.5 will be shed, >0.5 will be roundedSystem.out.println (Math.Round (15.5)); System.out.println (Math.Round (-15.5)); System.out.println (Math.Round (-15.51)); } { //generate random numbers with the random classList<integer> intlist =NewArraylist<integer>(); Random Random=NewRandom (); intCount = 0; while(Count <= 7) {Integer tem= Random.nextint (37); if(Intlist.contains (TEM))Continue; Else{intlist.add (TEM); Count++; }} System.out.println (Intlist); } { //subtraction of large integersBigInteger Biga =NewBigInteger ("132122332323232323"); BigInteger BIGB=NewBigInteger ("45648945649874645645645641231974816"); System.out.println (Biga); System.out.println (BIGB); System.out.println (Biga.multiply (BIGB)); } { //rounding of the number of sizesBigDecimal BD =NewBigDecimal ("12358645.22564"); System.out.println (Bd.divide (NewBigDecimal ("1"), 1, bigdecimal.round_half_up));; }}
Digital operations in Java