I would like to know how to check if a string is instance of a Class in a Server Side of ServerSocket programm. Α client gives an object of class Myclass1 and the server must check if a string that reads from client is instance of MyClass1 or another class(e.g. MyClass2, String, Integer, etc.)
That is my code:
ObjectInputStream object_input = new ObjectInputStream(sock.getInputStream());
String string = object_input.readLine();
if (string instanceof MyClass1){...}
else if(string instanceof MyClass2){...}
It makes an error and I don't know how to solve it. Please, help me