title: Is it possible to remove an attribute (variable) from object in java?
body: <p>I have a lots of classes that extends from one class</p>
  
  <p>Also I have one method that its argument is that parent class and create query base on attribute of those classes.</p>
  
  <p>sometimes I need to ignore some attribute from result query.</p>
  
  <p>so is it possible to remove some attribute of object?</p>
  
  <pre><code>class A1 extends Model {
      public String field1 = "";
      public String field2 = "";
  
      public String table = "A1";
  
      @Override
      public String getTable() {
          return this.table;
      }
  }
  
  class A2 extends Model {
      public String field1 = "";
      public String field2 = "";
      public String field3 = "";
  
      public String table = "A2";
  
      @Override
      public String getTable() {
          return this.table;
      }
  }
  
  class Utility {
      public static String query(Model params) {
          Field[] fields = params.getClass().getFields();
          String head = "INSERT INTO " + params.getTable() + "(";
          String tail = "VALUES (";
          for(Field field : fields) {
              String key = field.getName();
              String val;
              try {
                  val = field.get(params);
              } catch (Exception e) {
                  val = null;
              }
              head += key + ",";
              tail += "'" + val + "',";
          }
          head = head.substring(head,0,head.length() -1) + ")";
          tail = tail.substring(tail,0,tail.length() -1) + ")";
          return head + tail;
      }
  }
  </code></pre>
  
  <p>I call query method by sending one model</p>
  
  <pre><code>A1 data = new A1();
  data.field1 = "Name";
  data.field2 = "Family";
  String query = Utility.query(data);
  </code></pre>
  
  <p>I just want to remove field2 from query how can I do that?</p>
  
  <p>thanks for any help</p>