What exactly are Raw Types?
According to language specification , in free translation:
More precisely, a crude type is defined as one of the
The reference type that is formed by taking the name of a declaration of
generic type without a tracking type argument list.
An array type whose element type is a raw type.
A non-static member type of a raw type R that is not inherited from
a superclass or superinterface of R.
The term Raw Types became known with the introduction of Generics .
For example, I'll use Framework Collections :
When Collections was designed in Java version 1.2, a collection did not specify which type of object it would manipulate, that is, the collection could receive any type, as in the example:
List lista = new ArrayList();
Manipulating an unbalanced collection as it is is costly, because when you remove an element from the collection, you should assign it to its type, as well as being inconvenient, not safe.
Failure to report a type / argument to
List is known as a Raw Type, or in free translation, a crude type.
Solving the Raw Type:
To solve this problem, in version 1.5 of Java, Generics , with this, it was possible to inform one type of the collection, according to the example:
List<String> lista = new ArrayList<String>();
So, since the compiler knows the element type of the collection, the compiler can check that you have used the collection consistently and can insert the correct templates on the values that are being taken from the collection. >
And why are they a big problem?
In fact, Raw Types are a big problem, because even with the introduction of Generics it would not be convenient to remove Raw Types, since legacy applications need to continue working.