How to make a string compare non case sensitive?

后端 未结 2 1383
情书的邮戳
情书的邮戳 2021-01-25 15:58

I am trying to write a code for one of those programs that responds according to your answers. I want to make it so that some of the variables are not case sensitive. For exampl

2条回答
  •  时光取名叫无心
    2021-01-25 16:52

    Worth mentioning String#toLowerCase:

    name.toLowerCase().equals("me");
    

    Or simply use String#equalsIgnoreCase:

    name.equalsIgnoreCase("me");
    

提交回复
热议问题