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