How can we do the same piece of code in the single file

as it is written there in two different files and executed ,unlike that way how can we write it in single file.

yes we write this.
i have written this code below

hope this will help u
pls rate my work so that i can improve my work

import java.util.*;

public class linkedlist {

private class Node {
	int data;
	Node next;
}

private Node head;
private Node tail;
private int size;

public void display() {
	Node temp = head;
	for (int i = 0; i < size; i++) {
		System.out.print(temp.data + " ");
		temp = temp.next;
	}
	System.out.println();
}

public int size() {
	return size;
}

public void handlezerosize(int data) {
	Node nn = new Node();
	nn.data = data;
	nn.next = null;
	tail = nn;
	head = nn;
	size = 1;
}



public void addlast(int data) {
	if (size == 0)
		handlezerosize(data);
	else {
		Node nn = new Node();
		nn.data = data;
		nn.next = null;
		tail.next = nn;
		tail = nn;
		size++;
	}
}
    public static void main(String args[]) {
    	linkedlist l=new linkedlist();
    	l.addlast(5);
    	l.addlast(7);
    	l.addlast(8);
    	l.addlast(6);
    	l.display();
    }  
    }