Generics in Java - Generics in Throws Clause

Generics in Throws Clause

Although exceptions themselves cannot be generic, generic parameters can appear in a throws clause:

public void throwMeConditional (boolean conditional, T exception) throws T { if(conditional) throw exception; }

Read more about this topic:  Generics In Java

Famous quotes containing the words throws and/or clause:

    “As a particularly dramatic gesture, he throws wide his arms and whacks the side of the barn with the heavy cane he uses to stab at contesting bidders. With more vehemence than grammatical elegance, he calls upon the great god Caveat Emptor to witness with what niggardly stinginess these flinty sons of Scotland make cautious offers for what is beyond any question the finest animal ever beheld.”
    —Administration in the State of Arka, U.S. public relief program (1935-1943)

    “Long ago I added to the true old adage of “What is everybody’s business is nobody’s business,” another clause which, I think, more than any other principle has served to influence my actions in life. That is, What is nobody’s business is my business.”
    —Clara Barton (1821–1912)