src/textgen/MyLinkedList.java
/**
	 * Add an element to the list at the specified index
	 * @param The index where the element should be added
	 * @param element The element to add
	 */
Add an element to the list at the specified index
@param The index where the element should be added
@param element The element to add
Add an element to the list at the specified index @param The index where the element should be added @param element The element to add
public void add(int index, E element ) 
	{
		if(null==element){
			throw new NullPointerException();
		} else {
			if(index==0 && size()==0){			
				add(element);
			} else {			
				LLNode <E> newNode = new LLNode <E>(element);
				LLNode<E> currentNode=null;
				if(index<0 || (index>0 && index>=size)){
					throw new IndexOutOfBoundsException();
				} else {
					System.out.println("index is a proper value = "+index);
					System.out.println("head ="+head);
					currentNode=head;
					for(int i=0;i<=index;i++){
						currentNode=currentNode.next;
					}
					System.out.println(currentNode + " #$# "+ currentNode.prev);
					newNode.next=currentNode;
					newNode.prev=currentNode.prev;
					currentNode.prev.next=newNode;
					currentNode.prev=newNode;				
					size++;
				}
			}
		}
	}
public void add ( int index , E element ) { if ( null == element ) { throw new NullPointerException ( ) ; } else { if ( index == 0 && size ( ) == 0 ) { add ( element ) ; } else { LLNode < E > newNode = new LLNode < E > ( element ) ; LLNode < E > currentNode = null ; if ( index < 0 || ( index > 0 && index >= size ) ) { throw new IndexOutOfBoundsException ( ) ; } else { System . out . println ( "index is a proper value = " + index ) ; System . out . println ( "head =" + head ) ; currentNode = head ; for ( int i = 0 ; i <= index ; i ++ ) { currentNode = currentNode . next ; } System . out . println ( currentNode + " #$# " + currentNode . prev ) ; newNode . next = currentNode ; newNode . prev = currentNode . prev ; currentNode . prev . next = newNode ; currentNode . prev = newNode ; size ++ ; } } } }
Add an element to the list at the specified index
 @param The index where the element should be added
 @param element The element to add
Add an element to the list at the specified index @param The index where the element should be added @param element The element to add
// empty list // non empty list //System.out.println(" negative index ="+index);