java - How to increment array index -


i using arraylist in java program problem when add item in arraylist adding on same index want know how increment array index in array list.

arraylist arr = new arraylist(500); stringtokenizer st = new stringtokenizer(line, ":mode set - out of service in service"); while(st.hasmoretokens()){     arr.add(st.nexttoken()); } 

in above code keep adding item on same index i.e. arr[0].

do need initalize arraylist size? try original code changing

arraylist arr = new arraylist(500); 

for

arraylist arr = new arraylist(); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -