Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Vector of strings..... (http://www.go4expert.com/forums/vector-of-strings-t1817/)

boyracer87 5Nov2006 19:54

Vector of strings.....
 
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


All times are GMT +5.5. The time now is 00:23.