문제

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")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top