LabWork
This commit is contained in:
25
linkedList.java
Normal file
25
linkedList.java
Normal file
@@ -0,0 +1,25 @@
|
||||
//13. write a java program to demonstrate linked list
|
||||
import java.util.LinkedList;
|
||||
public class linkedList
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
LinkedList<String> StationList = new LinkedList<>();
|
||||
|
||||
StationList.add("Kharghar");
|
||||
StationList.add("Belapur");
|
||||
StationList.add("Nerul");
|
||||
|
||||
System.out.println("Station at Index 0: " +StationList.get(0));
|
||||
System.out.println("Station at Index 1: " +StationList.get(1));
|
||||
System.out.println("Station at Index 2: " +StationList.get(2));
|
||||
|
||||
System.out.println("Name of Stations in StationList:");
|
||||
for(String Station: StationList)
|
||||
{
|
||||
System.out.println(Station);
|
||||
}
|
||||
StationList.remove("Belapur");
|
||||
System.out.println("Size of StationList after removal: " +StationList.size());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user