You can use Guava intMath API to do the square root. But it’s not a wise idea to add dependency on an API just to avoid the cast. In casting, when you give the input as a perfect square int, you’ll get an integer-valued double which is in the int range. So casting doesn’t introduce any rounding error when you try to convert int to double or integer-valued double back to an int.
Interested in Java? Check out this Java tutorial by Intellipaat.