private int Index(String[] match,String keyword){
int m=0;
keyword=keyword+"1";
match[m]=match[m]+"1";
System.out.println("match:"+match[m]);
System.out.println("keyword:"+keyword);
System.out.println(match[m].equals(keyword));
while(!(match[m].equals("")) && !(match[m].equals(null))){
System.out.println("yes");
if(match[m].equals(keyword)){
break;
}
else
m++;
}
return m;
}
And I am getting following output (value of keyword is sparktg):
match:sparktg
1
keyword:sparktg1
false
Why in the case of match[m], there is a new line between “sparktg” & “1”?
If you have no control over the input, you can do a
trim()before you use the inputs. This eliminates any\nand spaces.You can make it cleaner by writing a utility method to do this.
and use it as so: