Ask Experts Questions for FREE Help !
Ask
    raidmax's Avatar
    raidmax Posts: 1, Reputation: 1
    New Member
     
    #1

    Apr 7, 2015, 11:41 AM
    Index out of bound
    Hi I'm getting index out of bound with the code below but I cannot find exactly what is causing the error.can anybody help.tnks

    import java.util.*;


    class allshortinVector
    {
    public static void main(String[] args)
    {
    Vector<String> v=new Vector();


    v.addElement("test");
    v.addElement("hello");
    v.addElement("JAVA");
    v.addElement("Program");


    Vector<String> v2=new Vector();


    for(int I=0 ; I < v.size() ; I++)
    {
    if( v.elementAt(I).length() < v.elementAt(I + 1).length() ) // checking which element is the longest
    {
    v2.addElement(v.elementAt(I)); // store them in vector v2
    }
    }
    for(String z : v2)
    System.out.println(z);
    }
    }

Check out some similar questions!

Bound [ 0 Answers ]

Bound girl I'm bound hooked and falling in love , you ask what sign she is you find that compatible realize how fine she is she's just what you been looking for

Bound by contract? [ 2 Answers ]

I own a small american owned mom and pop retail business .I use a merchant service and was not happy. In my attempt of changing companies I learned they were they only one my bank said they use.ok. So the bank says we have a customer service rep for them why not talk to him he convinced me to stay...

Bound to buying this used car? [ 5 Answers ]

Emailed back and forth with dealership and came to an agreed price through email only. No contract or money was exchanged but dealer removed the online ad for the car. If I decide I don't want it now do I have that right? Still no paperwork signed and no money exchanged. Only words through email.

Heaven bound? [ 6 Answers ]

Did you made your reservation for heaven?

Legally bound even after lease is up?! [ 4 Answers ]

Ok, here's the situation. My roommate and I signed a 10 month lease, and the lease is up on the 31st of this month. I am moving out because I've found a new job in another city. My roommate still wants to live in the apartment, so we started looking for people to fill the room. I've done all I...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.