title: Updating array in java
body: <p>I'm facing a problem with this code,please anyone can help me?</p>
  
  <pre><code>import java.util.Scanner;
  class A{
      int p[];
      int m,i;
      A(){
         p=new int[][10,20,30,40,50];
      }
      int sum(int p,int m){
         p+=m;
         return p;
     }
  }
  class B{
      int i,m;
      public static void main(String args[]){
          A object=new A();
          Scanner input=new input(System.in);
          m=input nextInt();
          for(i=o;i&lt;object.p.length;i++){
             if(m==object.p[i]){
                 n=object.sum(object.p[i],m);
                 object.p[i]=n;
              }
          }
          for(i=0;i&lt;object.p.length;i++){
              System.out.println(p[i]);}
          }
  </code></pre>
  
  <p>When i am taking 10 as input then it matches with the  first array value and then adds and becomes 20....But my problem is that when next time  i will run the program again,the value will not be changed(with adding results).......
  how can i update the value of p array after the method for further calculation:?  ``</p>