How to get index of Escape Character in a String?
String test="1234\567890";
System.out.println("Result : "+test.lastIndexOf("\\"));
Result i get: -1
Result i need: 4
Your original String doesn't contain \. Which means you are searching something which does not exist. Inorder to add \ to your string. You have to escape while adding
String test="1234\\567890";
System.out.println("Result : "+test.lastIndexOf("\\"));
Should work.

In your case look at the last line in the table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With