|
Im studying java programming and I came to a problem about the trim function. I need to get the string of the checkbox ("Office Visit ") with spaces..and I use trim() to remove the spaces and declared it in a String variable a
Here's my code.
###########################################################
public void itemStateChanged(ItemEvent e)
{ //where (e.getItem().toString = "Office Visit ")
String a = e.getItem().toString().trim();
//now a="Office Visit" or e.getItem().toString().trim()= "Office Visit"
if (a == "Office Visit") //HERE IS THE PROBLEM
{
lblService.setText("$10");
}
}
############################################################
THE PROBLEM IS..the statement (a == "Office Visit") I cannot make the if statement TRUE even the variable a is also "Office Visit"...I think the problem there is the trim() function but I dont know why.Please help!!!
|
|
|
|
|
|
|
// |