---
schema_version: "1"
id: 5bcfa5f77f7fc03a6cc0c20724466d66dd4bb9991a93ecfcaf5ea3f1d305b7bb
title: Parameterized Typing
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/langCon_apex_parameterized_types.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_parameterized_types.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 28c290f501978dd1499001ad777828b3403913b4cc67c321cb5076287de87f0f
description: Apex, in general, is a statically-typed programming language, which means users must specify the data type for a variable before that variable can be used.
---
# Parameterized Typing

Apex, in general, is a statically-typed programming language, which means users must specify the data type for a variable before that variable can be used.

This is legal in Apex:

Integer x = 1;

This is not legal, if x has not been defined earlier:

x = 1;

Lists, maps and sets are parameterized in Apex: they take any data type Apex supports for them as an argument. That data type must be replaced with an actual data type upon construction of the list, map or set. For example:

List<String\> myList = new List<String\>();

## Subtyping with Parameterized Lists

In Apex, if type T is a subtype of U, then List<T> would be a subtype of List<U>. For example, the following is legal:

List<String\> slst = new List<String\> {'alpha', 'beta'};
List<Object\> olst = slst;