
public class CirLinkedList<T> {
	Node<T> head=null;
	int size;
	
	
	public void print(){
		if(head==null)
			System.out.println("No Nodes");
		else{
			Node<T> pos= head;
			while(pos.getNext() != head){
				System.out.println(pos.getNext().toString());
				pos=pos.getNext();
			}
		}
	}
	
	public boolean add(T data){
		Node<T> newNode = new Node<>(data);
		if(head==null){
			head=new Node<>(null);
			head.setNext(newNode);
			newNode.setNext(head);
			++size;
			return true;
		}
		Node<T> pos= head;
		
		while(pos.getNext() != head)
			pos=pos.getNext();
		
		pos.setNext(newNode);
		newNode.setNext(head);
		++size;
		return true;
	}

}
