我是Java新手,我想使用f.i在长字符串中找到一个特殊字符。 lastIndexOf
或indexOf
,只是为了知道存在。
角色是十六进制0x1A
。如何在lastIndexOf
或indexOf
中使用十六进制?
您可以使用
其中之一
text.indexOf('u001A');
或
text.lastIndexOf((char) 0x1A);
看看这个java文档
可以通过这些函数的返回值来测试是否存在。
如果它返回 -1,则给定的字符串/char 不存在于源字符串中。