for what we use generics code example
Example 1: generic argument java
static void fromArrayToCollection(Object[] a, Collection<?> c) {
for (Object o : a) {
c.add(o); // compile-time error
}
}
Example 2: why use generic in real life in programming
object[] objectArray = new string[] { "string 1", "string 2" };