Determine if string starts with letters A through I

前端 未结 6 872
北海茫月
北海茫月 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:33

    if ( string.toUpperCase().charAt(0) >= 'A' && string.toUpperCase().charAt(0) <= 'I' )

    should be the easiest version...

提交回复
热议问题