Hello friends i am new to java programming. I am trying to develop a simple GUI based application to perform addition of two numbers.
Please have a look at my code
What i am expecting is whenever a user presses on the add button and if the input numbers are not provided then a message box much appear and display the error message.
The above code works fine and the box is also displaying but I need it to appear only after checking that if condition. If I place the JoptionPane line inside that if (Yes I have removed the block comment) nothing appears.
Hope you have understood my problem. Please help me guys
That is because you are using == to compare strings. The == operator compares references - in other words, it checks if the two arguments to the left and right of it refer to the exact same object. It does not compare the content of the objects.