I\'ve quickly googled for an answer but could not not find/think of accurate search parameters.
I am teaching myself Java, but can\'t seem to find the meaning of a certa
These are called Generics.
In general, these enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods.
Using generics give many benefits over using non-generic code, as shown the following from Java's tutorial:
Stronger type checks at compile time. A Java compiler applies strong type checking to generic code and issues errors if the code violates type safety. Fixing compile-time errors is easier than fixing runtime errors, which can be difficult to find.
For example:
// without Generics
List list = new ArrayList();
list.add("hello");
// With Generics
List list = new ArrayList();
list.add("hello"); // will not compile
Enabling programmers to implement generic algorithms. By using generics, programmers can implement generic algorithms that work on collections of different types, can be customized, and are type safe and easier to read.
Elimination of casts.
For example, the following code snippet without generics requires casting:
List list = new ArrayList();
list.add("hello");
String s = (String) list.get(0);
When re-written to use generics, the code does not require casting:
List list = new ArrayList();
list.add("hello");
String s = list.get(0); // no cast