Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 1
in future you can decide to use SoftwareEngineer instead Programmer, and if you use only Person methods this change is easy. (but I don't like this strategy too)
upcasting is useful by method arguments and return type, then method can work with more types (all subtypes)
+ 1
here it is necessary
import java.util.*;
public class MyClass {
public static void main(String args[]) {
/*java.util.ImmutableCollections.Map1<String,String> m =
Map.of("aa","bb"); //error */
Map<String,String> map =
Map.of("aa","bb");
System.out.println( map.getClass() );
map = Map.of("aa","bb","cc","dd");
System.out.println( map.getClass() );
}
}