Java- how to temporarily store data in array-list -


i want cache arrlist values available in class, define empty arrlist instially , adding values on method , trying global defined arralist values....

class test{       arraylist list=new arraylist();       public void addvalues(){          list.add("one");         list.add("two");         list.add("three");         list.add("four");         list.add("five");          getarrlstvalues();     }      public void getarrlstvalues(){          system.out.println("size of cache arralist=" +list.size());         //why showing 0 size     }       public static void main(string args[]) {      test obj=new test();      obj.addvalues();  } } 

in code add values this.list , check obj.getarrlstvalues(), when this != obj.

so never update same list at!

you can use this.getarrlstvalues() (or getarrlstvalues()) , remove line:

test obj=new test() 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -