0% found this document useful (0 votes)
36 views2 pages

Ex 13 Java

java program

Uploaded by

TRANAND TR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Ex 13 Java

java program

Uploaded by

TRANAND TR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ex.

13 Program implementing ArrayList

Source Code
import [Link];
import [Link];

public class StudentList


{
public static void main(String[] args)
{
ArrayList<String> students = new ArrayList<>();
Scanner scanner = new Scanner([Link]);

// Adding students to the ArrayList


[Link]("Enter student names (type 'stop' to finish):");
while (true)
{
[Link]("Enter student name: ");
String name = [Link]();

if ([Link]("stop"))
break;

// Add student to the list


[Link](name);
}

// Display the list of students


[Link]("\nList of students:");

for (String st : students)


[Link](st);
// Remove a student by name
[Link]("\nEnter the name of the student to remove: ");
String studentToRemove = [Link]();

if ([Link](studentToRemove))
[Link](studentToRemove + " has been removed.");
else
[Link](studentToRemove + " was not found in the list.");

// Display the updated list of students


[Link]("\nUpdated list of students:");

for (String st : students)


[Link](student);

[Link]();
}
}

You might also like