This question has already been answered:
- Java string immutability 5 replies
Good day.
There was one question. There is a condition for the input value:
private boolean isValid() { String message; //если < 10 if (Integer.parseInt(jtxtInput.getText()) < 10) message = "Минимальное значение: 10"; else return true; JOptionPane.showMessageDialog(frame, message, "Ошибка", JOptionPane.WARNING_MESSAGE); return false; } Remembering that String objects are immutable, I decided to check this and initialized the message:
String message = "test"; However, no error occurred. The question is why, because in fact we got a variable String?
Thank you.