安全发布原则

public class XXX {
  private String[] status = new String[] {"A", "B", ....};
  
  ...
  public String[] getStatus() { return status; }
}


status 由私有变公有

public class XXX {
  private String[] status = new String[] {"A", "B", ....};
  
  ...
  public String[] getStatus() { 
     String[] temp = new String[status.length()];
     for(int i=0; i<status.length(); i++) {
        temp[i] = new String(arr[i]);
     }
     return status; 
  }
}

你可能感兴趣的:(安全)