我试图解析一个字符串,我需要使用子字符串来做到这一点.该字符串包含撇号字符.我的问题是,如何使用temp来获取String.indexOf来获取撇号字符的索引?
//temp variable currently contains the string 'hello' including the apostrophe character
String finalWord = temp.substring(temp.indexOf('''), temp.indexOf('.')); 
您的变量名称错误(final是保留字),您应该使用转义字符:
String finalword = temp.substring(temp.indexOf('\''), temp.indexOf('.'));