小编Jen*_*nsS的帖子

Java:使用带有.endsWith的OR运算符

我有一堆字符串我想用.endsWith函数分隔它们.我想写这样的东西:

if (textString.endsWith("_xyz"))
   //do this
else if (textString.endsWith("_xyz" || "_pqr" || "_abc")) 
   throw new Error();
Run Code Online (Sandbox Code Playgroud)

是否可以使用.endsWith是否有另一种达到上述要求的最佳方式?

java string

-1
推荐指数
1
解决办法
315
查看次数

标签 统计

java ×1

string ×1