HackerRank - Cracking the Code Interview - Linked Lists: Detect a Cycle

Here's my Java solution for HackerRank and Cracking the Code Interview's Linked Lists: Detect a Cycle problem.

boolean hasCycle(Node head) {  
    if (head == null) return false;

    Node slow = head;
    Node fast = head;

    while (true) {
        slow = slow.next;

        if (fast.next != null) fast = fast.next.next;
        else return false;

        if (slow == null || fast == null) return false;

        if (slow == fast) return true;
    }
}