Skip to content

Instantly share code, notes, and snippets.

@championswimmer
championswimmer / C++ Templates vs Java Generics.md
Created July 28, 2018 01:20
C++ Templates vs Java Generics

Templates in C++ vs Generics in Java

Templates and generics allow us to achieve very similar results using very similar code syntax in C++ and Java respectively. But despite that, the implementation of these two features and their semantics are vastly different under the hood.

Syntax and Usage

Templates

Let us consider first the case of a template called Pair in C++.