Squares of a Sorted Array leetcode java solution

class Solution {
    public int[] sortedSquares(int[] nums) {
        //create a res arr to return result
        int[] res = new int[nums.length];
        //for storing the squares we will use 
        //priority Queue
        //create PriorityQueue
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for(int i=0;i<nums.length;i++){
            //add the squares of number into  pq
            pq.add(nums[i]*nums[i]);
        }
        //now poll the element from the pq
        //and store into res arrary
        int count = 0;
        while(!pq.isEmpty()){
            res[count] = pq.poll();
            count++;
        }
        return res;
    }
}