There is a void method that works when you click on a button : if in textfield 0, then nothing happens, if a different number appends 0.

Writes an "extra return statement". What should I do then?

 screenValue = Integer.parseInt(jTextField1.getText()); if (screenValue == 0) { return; } else { jTextField1.setText(String.valueOf(screenValue) + 0); } 
  • Add an example of the whole method - Grundy

1 answer 1

I will assume that the IDE message appears about the redundant return statement, not the compiler. Your example can be corrected as follows:

 screenValue = Integer.parseInt(jTextField1.getText()); if (screenValue != 0) { jTextField1.setText(String.valueOf(screenValue) + 0); } 

Or you can still simplify:

 String value = jTextField1.getText(); if (!"0".equals(value)) { jTextField1.setText(value + "0"); } 
  • Thank you, only now I understood the stupidity of the question. - Muscled Boy