Why is Serializable declared with full name in JDK classes?

This may be a little pointless question, but looking through the sources of the various JDK classes, I saw that when the class implemented the java.io.Serializable interface, it usually referred to it with the full name, without using import, for example, like:

 public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable 

Is there any specific reason for this? Does this have anything to do with the existence of the obsolete sunw.io.Serializable class from the old JDK 1.0?

+4
source share
1 answer

In general, it is considered a bad form to just import everything by will or not. Using full type names (including for java.io.Serializable and exceptions) reduces the need for import and checks where these types come from.

-2
source

Source: https://habr.com/ru/post/1392558/


All Articles