#uhhh idk what title give here
34 messages ยท Page 1 of 1 (latest)
โ This post has been reserved for your question.
Hey @unreal sleet! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Use String#isBlank:
if (cbCursoAcademico.getSelectedItem() == null || cbCursoAcademico.getSelectedItem().isBlank()) {
// ...
}
also, recommendations:
- I recommend not using string concatenation for
fila[0] = "" + c.getId();
fila[1] = "" + c.getCodigo();
// ...
instead, if those are integers and not strings, use
fila[0] = String.valueOf(c.getId());
fila[1] = String.valueOf(c.getCodigo());
// ...
- I recommend you cache the logger as a static variable:
private static final Logger = Logger.getLogger(jfrAlumnca.class)
the debugger tell me that cbCursoAcademico.getSelectedItem = (java.lang.String)""
my condition its: if cbCursoAcademico.getSelectedItem()==null || cbCursoAcademico.getSelectedItem().equals("")
so idk why the program don't enter into that if
i will try the is blank
using String#isBlank is just good practice
.isBlank its for java too? seems to dont suggest me it
what version of java are you using?
also, try slapping a log statement right before the if statement:
logger.log(Level.INFO, "Here is the string: '" + cbCursoAcademico.getSelectedItem() + "'");
^
show me what it outputs
ooh yah i have the blank thingie
Using the โ==โ operator for comparing text values is one of the most common mistakes Java beginners make. This is incorrect because โ==โ only checks the referential equality of two Strings, meaning if they reference the same object or not.
Let's see an example of this behavior:
String string1 = "using comparison operator"; String string2 = "using comparison operator"; String string3 = new String("using comparison operator"); assertThat(string1 == string2).isTrue(); assertThat(string1 == string3).isFalse();In the example above, the first assertion is true because the two variables point to the same String literal.
On the other hand, the second assertion is false because string1 is created with a literal and string3 is created using the new operator โ therefore they reference different objects.
yah == comparing string gives false
cz its another class
but i was just testing all i knew to see if any works x.x
the equals check the "value"
so gives true
but this time was blank, didnt knew that isblank were a thing
thank u!!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.