/ package codechef; // don't place package name! /
//represent,display,insertfirst done here
import java.util.;
import java.lang.;
import java.io.*;
/ Name of the class has to be "Main" only if the class is public. /
class Codechef
{
public ListNode head;
public static class ListNode{
public int data;
public ListNode next;
public ListNode(int data){
this.data=data;
this.next=null;
}
}
public void display(){
ListNode current=head;
while(current !=null){
System.out.println(current.data+" ");
current=current.next;
}
System.out.println("null");
}
public void insertfirst(int value){
ListNode newNode=new ListNode(value);
newNode.next=head;
head=newNode;
}
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Codechef sll=new Codechef();
// sll.head=new ListNode(20);
// ListNode second=new ListNode(90);
// ListNode third=new ListNode(80);
// sll.head.next=second;
// second.next=third;
sll.insertfirst(8765);
sll.insertfirst(067);
sll.display();
}
/ package codechef; // don't place package name! / //represent,display,insertfirst done here import java.util.; import java.lang.; import java.io.*;
/ Name of the class has to be "Main" only if the class is public. / class Codechef { public ListNode head; public static class ListNode{ public int data; public ListNode next; public ListNode(int data){ this.data=data; this.next=null; }
}