Substring between characters in Salesforce using apex

Sample Code:

String str1 = 'Hello';
String str2 = str1.substringBetween('H', 'o');
System.debug(str2);

Output: