!type
以下代码段是什么意思?为什么放!
?
String type = request.getParameter("tipo");
if (type == null) {
out.print("ERROR: The field type wasn't selected<br>");
}
if (!type.equals("auto")
&& !type.equals("trailer")
&& !type.equals("motorcycle")) {
out.print("ERROR: field error ("+type+")<br>");
}
有人能特别向我解释这个密码!type
吗?
类型是String
对象的实例,它具有方法,String#equals(...)
并且该方法返回一个boolean
...
“ ! ”这是求反运算符,它会反转任何布尔值...
因此,比较名称类型为String的var是否具有值“ auto”的结果!type.equals("auto")
是一个boolean
条件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句