By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

incomparable types: java.lang.string and int

P: 1
I wanted to ask about the code that I have made if either variable or any of ... thank you ...
"incomparable types: java.lang.string and int"
Expand|Select|Wrap|Line Numbers
  1.  if(StringUtils.isNullOrEmpty(txtIdPemesanan.getText())){
  2.         JOptionPane.showMessageDialog(null, "ID pemesanan tidak boleh kosong", "Larangan", JOptionPane.ERROR_MESSAGE);
  3.     }else{
  4.         pemesanan = pemesananController.findPemesanan(txtIdPemesanan.getText());
  5.         if (pemesanan.getIdPemesanan()== 0) {
  6.             JOptionPane.showMessageDialog(null, "Data yang dicari tidak ada!");
  7.         }else{
  8.         txtIdMarketing.setText(pemesanan.getMarketingIdmarketing()+"");
  9.         jDatePemesanan.setDate(pemesanan.getTanggal());
  10.         txtIdCustomer.setText(pemesanan.getCustomerIdcustomer()+"");
  11.  
  12.         CustomerJpaController customerController = new CustomerJpaController(emf);
  13.         Customer customer = customerController.findCustomer(pemesanan.getCustomerIdcustomer());
  14.         txtNamaCustomer.setText(customer.getNmCustomer());
  15.  
  16.         DetilbarangJpaController detilBarangController = new DetilbarangJpaController(emf);
  17.             javax.persistence.Query namedQuery = detilBarangController.getEntityManager().createNamedQuery("Detilbarang.findByPemesananIdPemesanan");
  18.         namedQuery.setParameter("pemesananIdPemesanan", pemesanan.getIdPemesanan());
  19.         List<Detilbarang> listDetilBarang = namedQuery.getResultList();
  20.         DefaultTableModel model = (DefaultTableModel) tblDetilBarang.getModel();
  21.         int i = 0;
  22.         while (i < tblDetilBarang.getRowCount()){
  23.             model.removeRow(i);

thanks for helpme...... :)
Sep 21 '12 #1
Share this Question
Share on Google+
1 Reply


100+
P: 126
i guess you are comparing a string with integer value 0
if you want to compare a string then use,

pemesanan.getIdPemesanan() == null
Nov 6 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.