Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package listapp;
- public class Node {
- private int Data;
- private Integer NextAddress;
- public Node(int InputData)
- {
- Data = InputData;
- NextAddress = null;
- }
- public void SetData(int InputData)
- {
- Data = InputData;
- }
- public void SetNextAddress(int InputNextAddress)
- {
- NextAddress = InputNextAddress;
- }
- public int GetData(){
- return Data;
- }
- public Integer GetNextAddress()
- {
- return NextAddress;
- }
- }
- package listapp;
- public class ListApp {
- public static void main(String[] args) {
- LinkedList x = new LinkedList(100);
- x.AddNodeAtEnd(10);
- x.AddNodeAtEnd(20);
- x.AddNodeAtEnd(30);
- System.out.println("");
- }
- }
- package listapp;
- public class LinkedList {
- Node[] LL;
- int CurrentIndex = 0;
- public LinkedList(int Size)
- {
- LL = new Node[Size];
- }
- public void AddNodeAtEnd(int Data)
- {
- Node temp = new Node(Data);
- if(CurrentIndex > 0){
- LL[CurrentIndex - 1].SetNextAddress(CurrentIndex);
- }
- LL[CurrentIndex] = temp;
- CurrentIndex++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement