function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Engine ForceEngine Force 

Parameterized Typing and Interfaces

public virtual interface Pair<T, U> {
    T getFirst();
    U getSecond();
    void setFirst(T val);
    void setSecond(U val);
    Pair<U, T> swap();
}

The above code from APEX guide does not compile with Error: Compile Error: type parameters not supported?

 

Thanks for the help!

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

You can't create parameterized classes at this time. Considering the specificness of the error message, it seems like parameterized typing is at least on the product roadmap (since its not a generic "unexpected token" exception).

All Answers

sfdcfoxsfdcfox

You can't create parameterized classes at this time. Considering the specificness of the error message, it seems like parameterized typing is at least on the product roadmap (since its not a generic "unexpected token" exception).

This was selected as the best answer
gaisergaiser

Support for Parameterized Interfaces has been dropped since Winter 13 release.

Parameterized interfaces are not supported in Apex saved using Salesforce.com API version 26.0 or later 

See "Salesforce.com Winter '13 Release Notes" page 173