For this Question: Given an integer K and a queue of integers, your task is  to reverse the order of the first K elements of the queue, leaving the other elements in the same relative order.User task:
Since this will be a functional problem, you don't have to take input. You just have to complete the functions:
 <b>ReverseK()</b>:-  that takes the Queue and the integer K as parameters.

Constraints:
1 &le; K &le; N &le; 10000
1 &le; elements &le; 10000
You need to return the modified Queue.Input 1:
5 3
1 2 3 4 5

Output 1:
3 2 1 4 5

Input 2:
5 5
1 2 3 4 5

Output 2:
5 4 3 2 1, I have written this Solution Code:  static Queue<Integer> ReverseK(Queue<Integer> queue, int k) { 
        
       
  
        Stack<Integer> stack = new Stack<Integer>(); 
  
        // Push the first K elements into a Stack  
        for (int i = 0; i < k; i++) { 
            stack.push(queue.peek()); 
            queue.remove(); 
        } 
  
          
        // Enqueue the contents of stack at the back  
        // of the queue 
        while (!stack.empty()) { 
            queue.add(stack.peek()); 
            stack.pop(); 
        } 
  
          
        // Remove the remaining elements and enqueue  
        // them at the end of the Queue 
        for (int i = 0; i < queue.size() - k; i++) { 
            queue.add(queue.peek()); 
            queue.remove(); 
        } 
        return queue;
    } 
  , In this Programming Language: Java, Now tell me if this Code is compilable or not?