Does the introduction of generics in Java increase the complexity of the program?

xiaoxiao2021-03-06  17

I don't know how everyone's ideas? I personally think that the readability of Java source code has indeed reduced much after introducing generic.

Here is the experiment I did using the Enummap class. (Enummap is the newly introduced Collection class in version 1.5)

Map Map = New Enummap (Fruit.class);

Map.put (Fruit.Apple, "Apple");

Map.Put (Fruit.watermelon, "Watermelon");

Map.put (Fruit.Orange, "Orange");

SET > set = map.entryset ();

For (Iterator > it = set.iterator (); it.hasnext ();)

{

Map.Entry Entry = it.next ();

System.out.println ("Key:" entry.getKey () "Value:" entry.getValue ());

}

// What is the feeling of reading the above?

转载请注明原文地址:https://www.9cbs.com/read-41750.html

New Post(0)