Switch to full style
General Java code examples
Post a reply

Data Structures: Vector

Thu Dec 09, 2010 1:27 pm

Code:
import java.util.*;

public class 
Test {
    
Vector list;
    
String[] codes = {"alpha""lambda""gamma""delta""zeta"};

    public 
Test(String[] userCodes){
        list = new 
Vector();
        
//load built-in codes
        
for(int i 0icodes.lengthi++){
            
addCode(codes[i]);
        }

        
//load user codes
        
for(int j 0userCodes.lengthj++){
            
addCode(userCodes[j]);
        }

        
//display all codes
        
for(Iterator ite = list.iterator(); ite.hasNext();){
            
String output = (String)ite.next();
            
System.out.println(output);
        }
    }

    private 
void addCode(String code){
        if(!list.
contains(code)){
            list.
add(code);
        }
    }

    public static 
void main(String args[]){
        
Test keeper = new Test(args);
    }




Post a reply
  Related Posts  to : Data Structures: Vector
 how we can search in filehandling without using structures a     -  
 Vector class     -  
 Iterator on Vector     -  
 vector front     -  
 C++ Vector capacity     -  
 count elements in a vector     -  
 Write Vector list to File     -  
 Support Vector Machine coding on Matlab...     -  
 c++/data structure     -  
 Data set for ID3 algorithm     -  

Topic Tags

Java Collections