public void addAtBegin(int item){
  Node nn = new Node(); = item;
  //attach new node to the previous node 
  if(this.size >= 1) = head;
    this.tail = nn;
  //shift head of previous node to the ned node
  this.head = nn;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter