title: How to Update JSONArray value on java
body: <p>can anyone help me, i'am new on java programing</p>
  
  <p>let say i have JSONArray with this data below :</p>
  
  <pre><code>[{
      "STATUSUPDATE": 0,
      "IDSERV": "2"
  }, {
     "STATUSUPDATE": 0,
     "IDSERV": "3"
  }, {
     "STATUSUPDATE": 0,
     "IDSERV": "1"
  }]
  </code></pre>
  
  <p>How to update <code>STATUSUPDATE</code> to <code>1</code> in <code>IDSERV</code> <code>2</code></p>
  
  <p>How to update <code>STATUSUPDATE</code> to <code>2</code> in <code>IDSERV</code> <code>3</code></p>
  
  <p>and was trying to loop the data</p>
  
  <pre><code>for (int i=0; i &lt; array.length; i++){
  JSONObject itemArr = (JSONObject)array.get(j);
  if(itemArr.get("IDSERV").equals(2)){
  //should be itemArr.set(with new val) 
  //but method *set* can cal; only on JSONArray not an JSONObject
  //and looping the next one 
  }
  }
  </code></pre>
  
  <p>can anyone help me</p>