title: Why do classes in the javax.sql package use new String(str)?
body: <p>Many classes in the javax.sql package use <code>new String(str)</code> constructor. For example:</p>
  
  <pre><code>public void setCatalogName(int columnIndex, String catalogName) throws SQLException {
      checkColRange(columnIndex);
      if (catalogName != null)
          colInfo[columnIndex].catName = new String(catalogName);
      else
          colInfo[columnIndex].catName = new String("");
  }
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>public void setUsername(String name) {
      if(name == null)
      {
          username = null;
      } else {
          username = new String(name);
      }
  }
  </code></pre>
  
  <p>And many more:</p>
  
  <blockquote>
    <p>javax.sql.rowset.serial.SerialStruct.SerialStruct(SQLData, Map>)
    javax.sql.rowset.serial.SerialStruct.SerialStruct(Struct, Map>)
    javax.sql.rowset.RowSetMetaDataImpl.setCatalogName(int, String)
    javax.sql.rowset.RowSetMetaDataImpl.setColumnLabel(int, String)
    javax.sql.rowset.RowSetMetaDataImpl.setColumnName(int, String)
    javax.sql.rowset.RowSetMetaDataImpl.setColumnTypeName(int, String)
    javax.sql.rowset.BaseRowSet.setCommand(String)
    javax.sql.rowset.BaseRowSet.setDataSourceName(String)
    java.text.DateFormatSymbols.setLocalPatternChars(String)
    javax.sql.rowset.BaseRowSet.setNull(int, int, String)</p>
  </blockquote>
  
  <p>What is the purpose of this? Isn't it creating unnecessary string instances on the heap?</p>