else if (select! = ("1" | "2" | "3"))
select, "1", "2" and "3" are of type String, so! = does not fit
else if (select! = ("1" | "2" | "3"))
select, "1", "2" and "3" are of type String, so! = does not fit
else if (!select.equals("1")||!select.equals("2")||!select.equals("3")) Strings other than "1", "2" or "3" can also be null . And if it turns out that the select string is null , then when checking the proposed @Tsyklop you will get a NullPointerException. Correctly check this: if(!"1".equals(select)&&!"2".equals(select)&&!"3".equals(select))
those. for any select value other than "1", "2" and "3" will be true .
Source: https://ru.stackoverflow.com/questions/798697/
All Articles
!Set.of( "1", "2", "3" ).contains( select ). In earlier versions, instead ofSet.ofyou can useArrays.asList- zRrr