1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Vector of strings.....

Discussion in 'Java' started by boyracer87, Nov 5, 2006.

  1. boyracer87

    boyracer87 New Member

    Joined:
    Nov 5, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hey guys

    I ahve a project due for collage soon and i hardly have it half done. im currently trying to make a vector of strings but when i try return the list, it only gives me the last one that i inserted...here is the piece of code:

    Code:
    String item = command.getSecondWord();
            
            if (item.equalsIgnoreCase("key1")){
    	      	System.out.println("You now have the first key\n");
    	        items.add("key1");
    	        System.out.print("Items in hand are: ");
    	        for(int i = 0; i < items.size() ;i++)
                        {
    		    System.out.print(items.elementAt(i));
                        System.out.print(" ");
    		    } 		
            }else if (item.equalsIgnoreCase("key2")){
                    System.out.println("You now have the second key\n");
    	 	items.add("key2");
    	 	System.out.print("Items in hand are: ");
                    for(int i = 0; i < items.size() ;i++)             
                        {
    		    System.out.print(items.elementAt(i));
                        System.out.print(" ");
                        }      
             }else{
                System.out.println("?????????????");
            
             }
    
    Could anyone tell me whats wrong..

    Cheers,
    ray
     

Share This Page