Java中不区分大小写 [英] Case insensitive in java

查看:834
本文介绍了Java中不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在为当前项目使用Java代码,但是我无法走得更远.是否有命令比较两个不区分大小写的字符串?

示例:

我得到了这个"TestParameter",但是如果我有这个"testparameter"或"TESTPARAMETER"或"TeStPaRaMeTeR"等,它也应该可以工作.

我为每一个答案感到高兴.



问候
epanjohura

Hey guys

I''m using java-code for my current project, but I can''t go further. Is there any commant, to compare two strings witch case insensitive?

Example:

I got this "TestParameter" but it should also work if i had this "testparameter" or "TESTPARAMETER" or "TeStPaRaMeTeR" and so on..


I''m glad about every answer.



Greetings
epanjohura

推荐答案

哈哈,我明白了=)

对于那些也需要这段代码的人:.equalsIgnoreCase()


问候
epanjohura
haha I got it =)

for those, who need also this piece of code: .equalsIgnoreCase()


Greetings
epanjohura


string1.compareToIgnoreCase(string2)
string1.compareToIgnoreCase(string2)


这篇关于Java中不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆