[Solved] Mixing different types


Mixing types is not a java concept however you can compare, which is what you are looking for. Since newvalid is an array lets loop it and see if valid is inside.

boolean contains = false;
for (char c : newvalid) {
  if (c == valid) {
    contains = true;
    break;
  }
}
if (contains) {
// do your stuff
}

cannot return a value from method whose result type is void

Means that in method with return declaration void you can not return a value, hmm maybe that’s exactly what is in the message…

I will highlight your code so that you can understand

public static void main(String[] args) //This is your method, see the void as return type

…..

return valid; //Here you try to return a char and this is not allowed, since it is declared void

To solve compilation problem, change return valid; to return;

1

solved Mixing different types