0% found this document useful (0 votes)
1 views1 page

Java

The Java program utilizes a Vector to manage a list of grocery items. It prompts the user to enter an item, checks if it is already in the Vector, and either removes it if present or adds it if not. Finally, it prints all the items in the Vector after the operation.

Uploaded by

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

Java

The Java program utilizes a Vector to manage a list of grocery items. It prompts the user to enter an item, checks if it is already in the Vector, and either removes it if present or adds it if not. Finally, it prints all the items in the Vector after the operation.

Uploaded by

guptavipul2726
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

*;
public class main{
public static void main(String[] args) {
Vector v=new Vector(5);
[Link]("MILK");
[Link]("ICE-CREAM");
[Link]("BREAD");
[Link]("SUGAR");
[Link]("EGG");

[Link]("ENTER THE ITEM");


Scanner sc= new Scanner([Link]);
String item = [Link]();

if([Link]( new String(item)))


{
[Link]("REMOVING THE ITEM AS IT IS PRESENT " + item);
[Link](new String(item));
}
else {
[Link]("ADDING ITEM "+ item );
[Link]( new String(item));

}
[Link]("ALL THE ITEMS"+ v );

}
}

You might also like