How to add items to a Vector in Java

1 Answer

0 votes
import java.util.Vector;
 
public class Program {
    public static void main(String[] args) {
        Vector vec = new Vector();
        
        vec.add("java");
        vec.add("c");
        vec.add("c++");
        vec.add("c#");
        
        System.out.println(vec);  
    }
}
  
  
  
/*
run:
  
[java, c, c++, c#]
  
*/

 



answered Feb 27, 2024 by avibootz
...