check string for specific characters? I am just wondering if it is possible to check a string for specific characters.  For example if my string is String mystr = "test"; and I wanted to check for the letter t at the beginning and if it is NOT there do something how would I go about this?

I have read about string.startsWith(string2); however it returns true or false, I want to be able to do "XYZ" if "ABC" isn't satisfied, and it would seem that string.contains isn't a thing.

To paraphrase, I am trying to create an if statement that will evaluate if a string starts with a certain character(s) and will do something if this condition is NOT met.
Have you tried the following?

if(!actualString.startsWith(expectedString)) {
  // do whatever you have to
}


BTW, that is what actually suggested in @EdgarBonet's comment.