String buttons[] = {"button1", "button2", "button3", "default"}; JOptionPane.showOptionDialog(null,"Message","Title",JOptionPane.NO_OPTION,JOptionPane.PLAIN_MESSAGE,null, buttons,"default");


whenever I type a if statement, it gives me an error under the buttons.
if (buttons = "button1"){
}

how do I make the error go away.

1 answer

buttons is an array. You cannot compare it to a string.
You need a separate string variable, say, button, to receive the input, and then you can compare.

Plus, "=" is the assignment operator. You probably meant to use "==", which is the logical comparison operator.

if (button == "button1") { ...

Clearly, you are just starting out, so be sure to consult java's excellent online documentation frequently.
Similar Questions
  1. Can you explain how to answer the following question?Information: Tally chart shows the widths of buttons collected (button
    1. answers icon 1 answer
    1. answers icon 1 answer
    1. answers icon 3 answers
  2. create java application7. The full details of each task should be displayed on the screen (using JOptionPane) after it has been
    1. answers icon 1 answer
more similar questions