0
have the class:
import javax.swing.JTextArea;
public class Semantico {
private String tipo;
private String variavel;
public void verificaSem(String stipo, String svariavel, JTextArea txtSemantico){
this.tipo = stipo;
this.variavel = svariavel;
String tipo2 = "int";
if (tipo==tipo2){
txtSemantico.setText(tipo);
}
}
}
This txtSemantico is in my main class, and I would like to write the contents of the variable type which is "int" if it is equal to the contents of Tipo2 which is also "int". The point is that it does not write. Detail, if I take the If condition and leave what is inside the If, it works. Thank you.
Probably the values are not equal, so do not write, it is a logic problem in the case. Debug the code and see if it’s really coming in the same. Tip: use
equals
to compare strings and not==
– user28595