how to compare on multiple classes in java?
问题 Right now, I have written at comparator that sorts an array of Integers and Strings. As you can see from the code, if the two classes aren't the same, then the String class takes the greater than value. However, this only allows for two classes. What if I want to add another primitive type to my array, such as Float? I'd have to add more code to to if-else statement. Is there a way to implement compare without having to add a statement for each additional class I want to compare? import java