[英]Does Java have an “in” or “not in” operator similar to Python?
我正在用Java開發一個項目,我想知道Java是否像下面的示例在Python中具有類似的“ in” /“ not in”運算符。
>>>"jim" in "jimbo"
>>>True
對於字符串,有:
"jimbo".contains("jim"); // true
檢查文檔中的String
。 還有startsWith
, endsWith
和matches
(使用正則表達式)。
不。 你應該做
"jimbo".contains("jim")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.