Raw Types
This lesson explains what raw types are.
We'll cover the following...
We'll cover the following...
Technical Quiz
1.
Consider the Printer
class below which is parametrized on type T
.
public class Printer<T> {
T item;
public Printer(T item) {
this.item = item;
}
public void consolePrinter() {
System.out.println(item.toString());
}
public void changeItem(T item) {
this.item = item;
}
}
Will the following code snippet compile, if we don’t supply any type arguments?
Printer printer = new Printer(5);
A.
Yes
B.
No
1 / 4
The snippet Printer printer = new Printer(5);
will compile just fine. When the actual type parameter is omitted, a raw type is created. Raw types ...