For this Question: Given a linked list consisting of N nodes, your task is to traverse the list and print its elements.<b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>printList()</b> that takes head node of the linked list as parameter.

<b>Constraints:</b>
1 <=N <= 1000
1 <=Node.data<= 1000For each testcase you need to print the elements of the linked list separated by space. The driver code will take care of printing new line.Sample input
5
2 4 5 6 7

Sample output
2 4 5 6 7

Sample Input
4 
1 2 3 5

Sample output
1 2 3 5, I have written this Solution Code: public static void printList(Node head) {
while(head!=null)
        {
        	System.out.print(head.val + " ");
        	
        	head=head.next;
        }
		
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?