ity ▁ ▁For ▁the ▁list ▁class ▁shown ▁above , ▁an ▁actual ▁generic ▁parameter ▁subst itut ing ▁for ▁G ▁can ▁be ▁any ▁other ▁available ▁class . ▁To ▁const rain ▁the ▁set ▁of ▁classes ▁from ▁which ▁valid ▁actual ▁generic ▁parameters ▁can ▁be ▁chosen , ▁a ▁generic ▁constraint ▁can ▁be ▁specified . ▁In ▁the ▁declaration ▁of ▁class ▁S ORT ED _ LIST ▁below , ▁the ▁generic ▁constraint ▁dict ates ▁that ▁any ▁valid ▁actual ▁generic ▁parameter ▁will ▁be ▁a ▁class ▁that ▁inher its ▁from ▁class ▁CO MP AR ABLE . ▁The ▁generic ▁constraint ▁ens ures ▁that ▁elements ▁of ▁a ▁S ORT ED _ LIST ▁can ▁in ▁fact ▁be ▁sorted . ▁ ▁class ▁▁▁▁ ▁S ORT ED _ LIST ▁[ G ▁-> ▁CO MP AR ABLE ] ▁ ▁Gener ics ▁in ▁Java ▁ ▁Support ▁for ▁the ▁gener ics , ▁or ▁" cont ain ers - of - type - T " ▁was ▁added ▁to ▁the ▁Java ▁programming ▁language ▁in ▁ 2 0 0 4 ▁as ▁part ▁of ▁J 2 SE ▁ 5 . 0 . ▁In ▁Java , ▁gener ics ▁are ▁only ▁checked ▁at ▁compile ▁time ▁for ▁type ▁correct ness . ▁The ▁generic ▁type ▁information ▁is ▁then ▁removed ▁via ▁a ▁process ▁called ▁type ▁er asure , ▁to ▁maintain ▁compatibility ▁with ▁old ▁JVM ▁implementations , ▁making ▁it ▁un available ▁at ▁runtime . ▁For ▁example , ▁a ▁List < String > ▁is ▁converted ▁to ▁the ▁raw ▁type ▁List . ▁The ▁compiler ▁inser ts ▁type ▁cast s ▁to ▁convert ▁the ▁elements ▁to ▁the ▁String ▁type ▁when ▁they ▁are ▁retrieved ▁from ▁the