Reputation: 21
I'm new in Java and I want to find a single special character in a long string, using f.i. lastIndexOf
or indexOf
, just to know about the existance.
The character is hex 0x1A
. How can I use hex in lastIndexOf
or indexOf
?
Upvotes: 1
Views: 1630
Reputation: 2441
existence can be tested by the return value of these functions.
if it returns -1 then the given string /char is not present in the source string.
Upvotes: 0
Reputation: 533500
You can use either
text.indexOf('\u001A');
or
text.lastIndexOf((char) 0x1A);
Upvotes: 2