How do I check if a string contains a list of characters?

后端 未结 8 750
小鲜肉
小鲜肉 2020-12-11 02:02

How do I check if a list of characters are in a String, for example \"ABCDEFGH\" how do I check if any one of those is in a string.

8条回答
  •  旧巷少年郎
    2020-12-11 03:06

    This seems like a Homework question... -_-

    You can use the String.contains() function.
    For example:

    "string".contains("a");
    String str = "wasd";
    str.contains("a");
    

    but you will need to call it once per every character you want to check for.

提交回复
热议问题