Skip to main content

Posts

Showing posts from 2017

Data Structures using Java

package com.test.count; /**   *     * @author Kiran   *   */ public class LinkedList { Node headNode ; /** *   This method appends the Node at the end of the List *   * @param data */ public void appendNode( int data ) { Node currentNode = headNode ; if ( currentNode == null ) { Node newNode = new Node( data ); headNode = newNode ; return ; } while ( currentNode .getNextNode()!= null ) { currentNode = currentNode .getNextNode(); } currentNode .setNextNode( new Node( data )); } /** * This method prints all the Nodes/Values of the   * LinkedList *   */ public void printNodes() { Node currentNode = headNode ; if ( currentNode == null ) { System. out .println( " The Node is Null" ); return ; } else { System. out .print( "   " + currentNode .getData()); while ( currentNode .getNextNode()!= null ) {