Java是否具有“in”属性或“不在”或运算符类似于Python? [英] Does Java have an "in" or "not in" operator similar to Python?
本文介绍了Java是否具有“in”属性或“不在”或运算符类似于Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个Java项目,我想知道Java是否在Python中有类似的in/not in运算符,如下例所示。
pre>
>>>jiminjimbo
>>> True
解决方案
对于字符串,有:
神保。载( 吉姆); // true
检查文档 String
。还有 startsWith
, endsWith
和匹配
(使用正则表达式)。
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.
>>>"jim" in "jimbo"
>>>True
解决方案
For strings there is:
"jimbo".contains("jim"); // true
Check the documentation for String
. There is also startsWith
, endsWith
and matches
(which uses regular expressions).
这篇关于Java是否具有“in”属性或“不在”或运算符类似于Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文