EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

 

import java.io.*;

import java.util.*;

 

class Node

{

int data;

Node next;

 

Node(int d)//50

{

data=d;//data=50

next=null;

}

}

class LinkedList

{

public static void main(String args[])

{

Node head=null;

 

Scanner s=new Scanner(System.in);

 

Node current=null;

 

for(int i=1;i<=5;i++)i=5<=5

{

System.out.println(“Enter the elements=”);//50

int a=s.nextInt();//a=50

 

Node n=new Node(a);//create a node inside memory

 

if(head==null)//if the list is empty

{

head=n;

current=n;

}

else

{

current.next=n;

current=n;

}

}

System.out.println(“Linked list elements=”);

Node temp = head;

while (temp!=null)

{

System.out.print(temp.data +” “);//10 20 30 40 50

temp=temp.next;

}

}

}

 

Linked list in java data structures

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer