Determine if string starts with letters A through I

前端 未结 6 756
北海茫月
北海茫月 2021-01-11 15:30

I\'ve got a simple java assignment. I need to determine if a string starts with the letter A through I. I know i have to use string.startsWith(); but I don\'t want to write,

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-11 16:19

    Try

    string.charAt(0) >= 'a' && string.charAt(0) <= 'j'
    

提交回复
热议问题