Check if string is a punctuation character

后端 未结 6 1955
我寻月下人不归
我寻月下人不归 2020-12-03 21:13

Let\'s say I have a String array that contains some letters and punctuation

String letter[] = {\"a\",\"b\",\"c\",\".\",\"a\"};

In letter[3]

6条回答
  •  醉话见心
    2020-12-03 21:31

    Do you want to check more punctuations other than just .?

    If so you can do this.

    String punctuations = ".,:;";//add all the punctuation marks you want.
    ...
    if(punctuations.contains(letter[a]))
    

提交回复
热议问题