user637646
user637646

Reputation: 21

lastindexof() and HEX 0x1A

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

Answers (2)

Harit Vishwakarma
Harit Vishwakarma

Reputation: 2441

Check out this java doc

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

Peter Lawrey
Peter Lawrey

Reputation: 533500

You can use either

text.indexOf('\u001A');

or

text.lastIndexOf((char) 0x1A);

Upvotes: 2

Related Questions