Check if given number is perfect square | Java program to find if x is a perfect square . ; Find floating point value of square root of x . ; if product of square root is equal , then return T / F ; Driver code
class GFG { static boolean isPerfectSquare ( int x ) { if ( x >= 0 ) { int sr = ( int ) Math . sqrt ( x ) ; return ( ( sr * sr ) == x ) ; } return false ; } public static void main ( String [ ] args ) { int x = 2502 ; if ( isPerfectSquare ( x ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }