-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColor.java
More file actions
33 lines (26 loc) · 889 Bytes
/
Copy pathColor.java
File metadata and controls
33 lines (26 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**Author: Anand A Jain
* Date:02-08-2025
* Remove an Element from a Vector
Create a Vector<String> with the elements "Red", "Green", "Blue", and "Yellow".
Remove "Green" and print the final contents of the vector.
*/
import java.util.*;
import java.util.Vector;
public class Color {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Vector<String> color = new Vector<>();
color.add("Red");
color.add("Green");
color.add("Blue");
color.add("Yellow");
System.out.println("Elements before removing green");
for(String i : color)
System.out.println(i);
color.remove("Green");
System.out.println("Elements after removing green");
for(String i : color)
System.out.println(i);
in.close();
}
}