title: How to fix " - " to be shown in a string in Java?
body: <p>I have a problem where in my code below. I try to set my label to show " - " on particular string if the job_group has a " " then set the label with " - ". But, in this case the job_group does not show " - " inside the string? Is there a way to fix this issue? </p>
  
  <pre><code>import java.io.IOException;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import javax.faces.bean.ApplicationScoped;
  import javax.faces.bean.ManagedBean;
  import javax.faces.context.ExternalContext;
  import javax.faces.context.FacesContext;
  
  import org.springframework.jdbc.core.RowMapper;
  
  
  @ManagedBean(name = "jobSearchItemMapper")
  @ApplicationScoped
  public class JobSearchItemMapper implements RowMapper {
   @Override
      public Object mapRow(ResultSet rs, int i) throws SQLException {
          JobSearchItem jobItem = new JobSearchItem();
  
      jobItem.setid(rs.getString("JOB_CLASS_CD") + (rs.getString("PAY_GRADE")) + rs.getString("JOB_GROUP"));
      jobItem.setValue(rs.getString("JOB_CLASS_CD") + (rs.getString("PAY_GRADE")) +  rs.getString("JOB_GROUP") );
  
         if (rs.getString("JOB_GROUP").equals(" ")) {
  
            jobItem.setlabel(rs.getString("JOB_CLASS_TITLE")   +  " - "   +   rs.getString("JOB_GROUP") + " (" + (rs.getString("JOB_CLASS_CD"))   + "-" + (rs.getString("PAY_GRADE")) + ")");
  
        } else {
  
          jobItem.setlabel(rs.getString("JOB_CLASS_TITLE")    +     " - " +    rs.getString("JOB_GROUP") + " (" + (rs.getString("JOB_CLASS_CD")) + (rs.getString("PAY_GRADE")) + ")");
  
        }
  
         if (rs.getString("PAY_GRADE").equals("0")) {
  
         jobItem.setlabel(rs.getString("JOB_CLASS_TITLE")  +   "  " +  rs.getString("JOB_GROUP") + " (" + (rs.getString("JOB_CLASS_CD")) + ")");
  
          } else {
              jobItem.setlabel(rs.getString("JOB_CLASS_TITLE") +   "  " +  rs.getString("JOB_GROUP") + " (" + (rs.getString("JOB_CLASS_CD")) + "-" + (rs.getString("PAY_GRADE")) + ")");
          }
  
          return jobItem;
  
      }
  
  }
  </code></pre>