[英]Does Java have an “in” or “not in” operator similar to Python?
I'm working on a project in Java and I wanted to know if Java had a similar "in"/"not in" operator in Python like the example below. 我正在用Java开发一个项目,我想知道Java是否像下面的示例在Python中具有类似的“ in” /“ not in”运算符。
>>>"jim" in "jimbo"
>>>True
For strings there is: 对于字符串,有:
"jimbo".contains("jim"); // true
Check the documentation for String
. 检查文档中的String
。 There is also startsWith
, endsWith
and matches
(which uses regular expressions). 还有startsWith
, endsWith
和matches
(使用正则表达式)。
Nope. 不。 You should do 你应该做
"jimbo".contains("jim")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.