我正在编写一个程序来比较几个字符与Char数组并返回数组的索引.有没有可能比较忽略情况的方法?例如下面:
String in = "I AM A HAPPY BOY";
char[] cha = new char[] {a,c,e,g,i,k,h,m,o,q,s,u,w,y};
char testChar = in.substring(4,5).charAt(0);
for(int a = 0; a<char.length; a++){
if(cha[a] == testChar)
return a+1;
}
Run Code Online (Sandbox Code Playgroud)
我无法得到索引,因为它总是指向0.无论如何都要忽略这里的情况?感谢一些建议.
java ×1