/* TestGenerics4.java CIS 260 David Klick 1/28/2010 This program demonstrates how Java generics can also be applied to a return type. */ public class TestGenerics4 { public static void main(String[] args) { Integer[] nums = { 2, 4, 6, 8, 10 }; String[] names = { "Toby", "Rob", "Rebecca", "Matt", "Dave" }; System.out.println(getRandom(nums)); System.out.println(getRandom(names)); } private static E getRandom(E[] a) { return a[(int)Math.floor(Math.random()*a.length)]; } }