How to check if a string starts with one of several prefixes?

前端 未结 7 1172
广开言路
广开言路 2020-11-27 06:04

I have the following if statement:

String newStr4 = strr.split(\"2012\")[0];
if (newStr4.startsWith(\"Mon\")) {
    str4.add(newStr4);
}

I

7条回答
  •  青春惊慌失措
    2020-11-27 06:34

    When you say you tried to use OR, how exactly did you try and use it? In your case, what you will need to do would be something like so:

    String newStr4 = strr.split("2012")[0];
    if(newStr4.startsWith("Mon") || newStr4.startsWith("Tues")...)
    str4.add(newStr4);
    

提交回复
热议问题