Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why should int be enclosed in brackets in Java programming?
Why should int be enclosed in brackets in Java programming?
This is a cast, and the type in parentheses is the cast type. Because the random number generated by random is floating point number, the precision of floating point number in JAVA is higher than that of integer number, so it can't be automatically converted, and it must be forced to be converted by display. For example:

int a,b;

Double c = a * b;; //This compilation can be done through.

Double a, b;

int c = a * b; //If compilation is really not feasible, change it to int c = (int) a * b; Do it.

JAVA precision from low to high is as follows:

Byte integer floating-point double precision