Java method to check if linked list is circular