If I am not wrong, you have to use the .equals()
instead of ==
if((String) tprojekty.getValueAt(0,1).equals("xxx")) {
سؤال
I've been having this problem.. I read with HSSF xls cell (which value is lets say "turbox" value this way:
String hssfstanskup = sheet.getRow(p).getCell(3).getStringCellValue();
then, I create a row in my JTablel like this:
model.addRow(new Object[] { hssfstanskup } );
but if I create if statement like this:
if((String) tprojekty.getValueAt(0,1) == "xxx"){
it doesnot work...
extra info: tprojekty = new JTable(model); can anyone help me with this? thanks in advance!
المحلول
If I am not wrong, you have to use the .equals()
instead of ==
if((String) tprojekty.getValueAt(0,1).equals("xxx")) {
نصائح أخرى
In order to compare strings in java you use the .equals()
method instead of ==
.
Please try:
if((String) tprojekty.getValueAt(0,1).equals("xxx"))
which should solve your problem! The answer for this could have been found though with a simple Google search, or checking previous posts on StackOverflow! So in future take a look around for a solution before you post a question.