What’s the syntax of the following statement, “If an array element matches any of the elements of another array, then…”? I need it for my checkType() method. It’s a basic question, but a google search, albeit a perfunctory one, didn’t yield any results
UPD: So I now have this crazy new checkType() method. I decided to compare the contents of the two arrays using nested for loops (they used this procedure to traverse two-dimensional arrays in Learn Java). The method is called on an object with String stringValue and String type fields. “im” stands for “integer mutant”, it’s supposed to be assigned to objects whose stringValue starts with an integer or a dot, but continues with something else. “bi” is for “big” integers (of more than ten). “i” is for regular integers. “d” is for decimals. “r” is for Romans. “rm” is for “Roman mutants”. “g” is for other types of garbage input . I inputted an object with a stringValue of 2.5, and it returned “im” instead of “d”. For some reason, it didn’t find the dot in the standardArabChars array, and the condition charArray[j] != standardArabChars[y] was true. Could you tell me why it happened and how to fix it? But generally speaking, the initial question still stands
public String checkType() {
char[] standardArabChars = new char[11];
for(int i = 0; i < standardArabChars.length - 1; i++){
standardArabChars[i] = (char)('0' + i);
}
standardArabChars[10] = '.';
char[] standardRomanChars = new char[26];
for(int i = 0; i < standardRomanChars.length; i++){
standardRomanChars[i] = (char)('A' + i);
}
char[] charArray = stringValue.toCharArray();
for(int i = 0; i < standardArabChars.length; i++){
if(charArray[0] == standardArabChars[i]){
for(int j = 1; j < charArray.length; j++){
for(int y = 0; y < standardArabChars.length; y++){
if(charArray[j] != standardArabChars[y]){
return type = "im";
} else if(charArray[j] == '.') {
return type = "d";
} else {
if(Integer.decode(stringValue) > 10) {
return type = "bi";
} else {
return type = "i";
}
}
}
}
}
}
for(int i = 0; i < standardRomanChars.length; i++){
if(charArray[0] == standardRomanChars[i]){
for(int j = 1; j < charArray.length; j++){
for(int y = 0; y < standardRomanChars.length; y++){
if(charArray[j] != standardRomanChars[y]){
return type = "rm";
} else {
return type = "r";
}
}
}
}
}
return type = "g";
}