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).
Nope. You should do
"jimbo".contains("jim")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.