Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Simple Linked List Program in Java
WhatsApp
Alagunila Meganathan
Aug 03
2016
434
0
0
LinkedListDemo.rar
import
java.util.*;
public
class
LinkedListDemo{
public
static
void
main(String[] args){
LinkedList link=
new
LinkedList();
link.add(
"a"
);
link.add(
"b"
);
link.add(
new
Integer(
10
));
System.out.println(
"The contents of array is"
+ link);
System.out.println(
"The size of an linkedlist is"
+ link.size());
link.addFirst(
new
Integer(
20
));
System.out.println(
"The contents of array is"
+ link);
System.out.println(
"The size of an linkedlist is"
+ link.size());
link.addLast(
"c"
);
System.out.println(
"The contents of array is"
+ link);
System.out.println(
"The size of an linkedlist is"
+ link.size());
link.add(
2
,
"j"
);
System.out.println(
"The contents of array is"
+ link);
System.out.println(
"The size of an linkedlist is"
+ link.size());
link.add(
1
,
"t"
);
System.out.println(
"The contents of array is"
+ link);
System.out.println(
"The size of an linkedlist is"
+ link.size());
link.remove(
3
);
System.out.println(
"The contents of array is"
+ link);
System.out.println(
"The size of an linkedlist is"
+ link.size());
}
}
Java
Linked List
Up Next
Simple Linked List Program in Java