Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did language designers use angle brackets instead of parenthesis?

Reading through the javase api docs, I noticed that pretty much all of the methods in the collections framework use angle brackets. For example:

Collection<String> c = new HashSet<String>();

or

Map<String, Integer> m = new HashMap<String, Integer>();

To the eye they seem to serve the same function as a set of parentheses. I still don't know enough of the Java language to be able to see an overarching connection where angle brackets are used and why that might be the case.

My question is specifically: Is there a significance to the way angle brackets are interpreted by the JVM as opposed to perens? Or is it just a common practice across multiple languages?

like image 448
Steve the Maker Avatar asked Dec 05 '22 17:12

Steve the Maker


1 Answers

The angle brackets came with the introduction of generics in Java 1.5

Since this is a later addition to an existing language, I guess the angle brackets where chosen to make a clear distinction to the existing parentheses (method and constructor calls), square brackets (array member access) and curly brackets (block delimiters). I'd say angle brackets are the logical choice here.

like image 165
Sean Patrick Floyd Avatar answered Dec 07 '22 06:12

Sean Patrick Floyd