Hello to the community.
Is it possible (and if so, is it worth it) to do without conditional constructions if you need to use different algorithms for different types of input data?
For example, there is a table with data (you can walk through the cells) and there is an array of values of the appropriate dimension, which should be in this table. Each of the values can be of one of several types (suppose, String or Image) and must be checked against the cell in its own way. Is it possible to organize a check so as to avoid (not transfer, but not use at all) constructions like
if (expected instanceof String) {...}
As I understand it, if it is possible, then with the help of generalizations, but I cannot figure out how.
UPD. Values for checking are stored in variables of the same type - Object, since they are passed through a single structure (for example, like this: Object[] expectedValues
). Therefore, it does not work to rely on type checking when compiling.